Python Flashcards
Strings
How can you slice a string?
[start index:end Index:Step]
[1:2:2] end index - does not include the provided value
command to make all lower casses to upper casses letters
.upper()
convert lower case to upper and upper to lower case letters
.swapcase()
converts the first letter to capital letters
.capitalize()
find a substring of a string
some_string.find(what to find)
True or false answer - is something in a string
‘Searchparameter’ in ‘variable that saves the srting’
‘ing’ in a
count the occurence of a substring
variable.count(parameter)
a.count(a)
replace in substrings
.replace(‘what’,’replace with’)
a.replace(‘x’,’y’)
string concatinate
‘string1’+’string2’=string1string2
string repetition
3*a evaluates to aaa