Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- s = "Hello Python!"
- # convert all characters to lowercase
- print(s.lower())
- # output : hello python!
- # convert all characters to uppercase
- print(s.upper())
- # output : HELLO PYTHON!
- # check if string starts with 'He'
- print(s.startswith('He'))
- # output : True
- # check if string ends with '?'
- print(s.endswith('?'))
- # output : False
- # replace a portion of string
- s2 = s.replace('Python', 'C++')
- print(s2)
- # output : Hello C++!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement