Strings - RaspPywriter/Python-Data-Structures GitHub Wiki

string.lower()

Turns a string into all lowercase letters

Example

a.lower()

string_name.lower()

Turns a string into all uppercase letters

Example

string_name.upper()

string.replace("what to replace", "replace to this")

Example

s_name = "Test Subject" s_name.replace("T", "J") --> becomes s_name = "Jest Subject"

string.split()

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:

format()

The format() method can be used to insert numbers into strings.

Example:

age = 36 txt = "My name is John, and I am {}" print(txt.format(age))