Advertisement
Guest User

Untitled

a guest
Feb 29th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. text = "How are you?"
  2. print(text[0])
  3. print(text[1])
  4. print(text[2])
  5. print(text[11])
  6. print(text[-1])
  7. print(text[-2])
  8.  
  9.  
  10. H
  11. o
  12. w
  13. ?
  14. ?
  15. u
  16.  
  17. for i in range(0,len(text)):
  18. print(i, text[i])
  19.  
  20.  
  21. 0 H
  22. 1 o
  23. 2 w
  24. 3
  25. 4 a
  26. 5 r
  27. 6 e
  28. 7
  29. 8 y
  30. 9 o
  31. 10 u
  32. 11 ?
  33.  
  34. new_string = text[::-2]
  35. print(new_string)
  36. ?o r o
  37.  
  38.  
  39. # len()
  40. # upper()
  41. # lower()
  42. # title()
  43. # count()
  44. # find()
  45. # replace()
  46. # strip()
  47. # lstrip()
  48. # rstrip()
  49.  
  50.  
  51. text = "How are you?"
  52. print(len(text))
  53. print(text.upper())
  54. print(text.lower())
  55. print(text.title())
  56.  
  57. 12
  58. HOW ARE YOU?
  59. how are you?
  60. How Are You?
  61.  
  62.  
  63. text = " Nayeem "
  64. star = "*********"
  65. print(star+text.lstrip()+star)
  66. print(star+text.rstrip()+star)
  67. print(star+text.strip()+star)
  68.  
  69.  
  70. text = " Hello World "
  71. print(star+text.strip()+star)
  72. new_string = text.replace(" ","")
  73. print(new_string)
  74.  
  75. *********Nayeem *********
  76. ********* Nayeem*********
  77. *********Nayeem*********
  78. *********Hello World*********
  79. HelloWorld
  80.  
  81.  
  82. # count("word/letter",start, end)
  83. text = "where there is a problem there is a solution"
  84. print(text.count("is",16,20))
  85.  
  86. 0
  87.  
  88.  
  89. # replace("<pass string>","<pass string>",<pass integer>)
  90. text = "where there is a problem there is a solution"
  91. print(text.find("is",13))
  92. text = text.replace("is","are",20)
  93. print(text)
  94.  
  95.  
  96. 31
  97. where there are a problem there are a solution
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement