string methods Flashcards
1
Q
method to find length of string
A
print(len(name))
2
Q
method to find what position letter is in
A
print(name.find(“e”))
3
Q
method to capitalize first letter of string
A
print(name.capitalize())
4
Q
method to write string in all caps
A
print(name.upper())
5
Q
method to write string in all lowercase letters
A
print(name.lower())
6
Q
method to check if variable is a number
A
print(name.isdigit())
7
Q
method to check if variable are letters
A
print(name.isalpha())
8
Q
method to find how many letters are in the string
A
print(name.count(“e”))
9
Q
method to replace letter with another letter
A
print(name.replace(“e”, “a”))
10
Q
method to multiply string by a number
A
print(name*3)