Advertisement
ZEdKasat

strings practice questions hint

Mar 20th, 2022
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1. # ## 1
  2.  
  3. # text = "This is A STrinG with WEird Casess.."
  4.  
  5. # print(text.lower())
  6. # print(text.upper())
  7. # print(text.swapcase())
  8.  
  9.  
  10. # ## 2
  11.  
  12. # paragraph = "a bc d. ef gh ij. kl mn o. pqrs t"
  13. # print(paragraph.split())
  14. # sentence_list = paragraph.split(". ")
  15.  
  16. # for s in sentence_list:
  17. #     print(s)
  18.  
  19.  
  20. ## 3
  21.  
  22. # w = input("Enter a word: ")
  23. word_string = "football"
  24. if word_string.count("o") == 2:
  25.     print("valid spelling")
  26. else:
  27.     print("check spelling")
  28. # word_list = list(word_string)
  29. # print(word_list)
  30.  
  31. # for index in word_list:
  32. #     ## c = o
  33. #     index = "o".upper()
  34.  
  35. # word_list => list
  36. # len(word_list) => number of characters in the word(list)
  37. # range(len(word_list)) = [0,1,2,3,4,5,6,7]
  38.  
  39. # for index in range(len(word_list)):
  40. #     if word_list[index] in "aeiou":
  41. #         word_list[index] = word_list[index].upper()
  42. #     else:
  43. #         word_list[index] = word_list[index].lower()
  44. # word_string = "".join(word_list)
  45. # print(word_string)
  46.  
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement