Strings Flashcards
1
Q
How to escape / make effects?
A
\
2
Q
How to tab text?
A
\t
3
Q
How to newline?
A
\n
4
Q
How to combine strings?
A
+
5
Q
How to duplicate string?
A
‘string’ * 2 == ‘stringstring’
6
Q
How to slice every other character?
A
string[::2]
7
Q
What’s a string function?
A
string.function(argument)
8
Q
How to split?
A
string.split(x)
Ex: ‘string’.split(‘i’) == [‘str’, ‘ng’]
9
Q
How to join?
A
string. join(list)
e. g. ‘ ‘.join([‘ben’, ‘fred’] == ‘ben fred’
10
Q
Swap upper and lowercase?
A
string.swapcase()
11
Q
How to replace one string part with another?
A
string.replace(‘old’, ‘new’, how many instances to replace?)