Unit 11 Flashcards
11.1 - String Slicing
What is slice notation?
reading multiple characters in a string using my_str[a:b]
my_str = string, a/b = ints
11.1 - String Slicing
What is a stride?
the number of steps determines how much to increment while parsing the input string
my_str[0:10:2]
11.2 - Advanced String Formatting
What is field width?
the minimum number of characters inserted into the string to print a chart-like display
{'test':16}
11.2 - Advanced String Formatting
What is an alignment character?
determines how a value should be aligned in filed width
left (<), right (>), and centered (^)
11.2 - Advanced String Formatting
What is a fill character?
used in padding “free space” in a string
{score:0>4}
11.3 - String Methods
What does .replace(a, b)
do?
copy of a string, all occurrences of a is replaced with b
11.3 - String Methods
What does .find(a)
do?
returns the index of the first occurrence in a string
11.3 - String Methods
What does .count(a)
do?
returns the number of times a appears in a string
11.3 - String Methods
What does .isalnum()
do?
true if all characters are letters
11.3 - String Methods
What does .isdigit()
do?
true if all characters are numbers 0-9
11.3 - String Methods
What does .islower()
do?
true if all characters are lowercase
11.3 - String Methods
What does .isupper()
do?
true if all characters are uppercase
11.3 - String Methods
What does .isspace()
do?
true if all characters are whitespace
11.3 - String Methods
What does .startswith(x)
do?
true if string starts with x
11.3 - String Methods
What does .endswith(x)
do?
true if string ends with x