1.1 KiB
1.1 KiB
id, source_exercise_id, title, section, source_path, source_repo, source_commit, student_visible_solution, has_private_solution, skip
| id | source_exercise_id | title | section | source_path | source_repo | source_commit | student_visible_solution | has_private_solution | skip |
|---|---|---|---|---|---|---|---|---|---|
| practical-python-1.16 | 1.16 | String Methods | 1.4 Strings | 01_Introduction/04_Strings.md | https://github.com/dabeaz-course/practical-python | 93dca856b41c61a0a0f85ae334116e4c125629ea | false | false | false |
Exercise 1.16: String Methods
Source: Practical Python Programming,
01_Introduction/04_Strings.md.
Exercise 1.16: String Methods
At the Python interactive prompt, try experimenting with some of the string methods.
>>> symbols.lower()
?
>>> symbols
?
>>>
Remember, strings are always read-only. If you want to save the result of an operation, you need to place it in a variable:
>>> lowersyms = symbols.lower()
>>>
Try some more operations:
>>> symbols.find('MSFT')
?
>>> symbols[13:17]
?
>>> symbols = symbols.replace('SCO','DOA')
>>> symbols
?
>>> name = ' IBM \n'
>>> name = name.strip() # Remove surrounding whitespace
>>> name
?
>>>