Last active
June 10, 2018 12:18
-
-
Save martin-martin/541835318a3d3c878607f7d4681e9251 to your computer and use it in GitHub Desktop.
CheerySoreSequel created by martin_martin - https://repl.it/@martin_martin/CheerySoreSequel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name = 'codingnomads' | |
# trying to change the string directly causes an error | |
# name[8:] = 'rmals' | |
# TypeError: 'str' object does not support item assignment | |
# we need to create a new string | |
new_name = name[:8] + 'rmals' # using string slicing and concatenation | |
print(name, new_name) | |
# after re-assigning the value, the old 'name' is overwritten | |
name = new_name | |
print(name, new_name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment