Professional Documents
Culture Documents
PYTHON - Strings Notes
PYTHON - Strings Notes
STRINGS
“Mountains”.upper()
‘MOUNTAINS’
“Mountains”.lower()
‘Mountains’
“ yes “.strip()
‘yes’
“ yes “.lstrip()
‘yes ’
“ yes “.rstrip()
‘ yes’
COUNT:
“Forest”.endswith(“rest”)
True
ISNUMERIC:
“Forest”.isnumeric()
False
“1234”.isnumeric()
True
int(“1000”) + int(“1000”)
2000
Fill in the gaps in the initials function so that it returns the initials of the words contained in
the phrase received, in upper case. For example: "Universal Serial Bus" should return "USB";
"local area network" should return "LAN”.
def initials(phrase):
words = phrase.split()
result = ""
result += word[0].upper()
return result
name = “Manny”
number = “20”
print(“{} you chose {}”.format(name, number))