-
Notifications
You must be signed in to change notification settings - Fork 0
Strings
RaspPywriter edited this page Jun 28, 2020
·
3 revisions
Turns a string into all lowercase letters
a.lower()
Turns a string into all uppercase letters
string_name.upper()
s_name = "Test Subject" s_name.replace("T", "J") --> becomes s_name = "Jest Subject"
s_name = "Two, Words" s_name.split(",") --> splits the string into a list with two elements: ['Two', ' Words']
The format() method takes the passed arguments, formats them, and places them in the string where the placeholders {} are:
The format() method can be used to insert numbers into strings.
age = 36 txt = "My name is John, and I am {}" print(txt.format(age))