Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. s = "Hello Python!"
  2.  
  3. # convert all characters to lowercase
  4. print(s.lower())
  5. # output : hello python!
  6.  
  7. # convert all characters to uppercase
  8. print(s.upper())
  9. # output : HELLO PYTHON!
  10.  
  11. # check if string starts with 'He'
  12. print(s.startswith('He'))
  13. # output : True
  14.  
  15. # check if string ends with '?'
  16. print(s.endswith('?'))
  17. # output : False
  18.  
  19. # replace a portion of string
  20. s2 = s.replace('Python', 'C++')
  21. print(s2)
  22. # output : Hello C++!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement