Strings Flashcards
“Hello”
str
‘hello’
str
“ I don’t do that “
str
String is
Ordered sequences
Index and slicing str:
Used to grab sub sections of the string
Indexing allows grabbing a:
A section of a string.
Indexing notation uses:
[] Notation after the string (or variable assigned the string)
Indexing =
[] and a number index indicating position of what to grab
Character: h e l l o
Index: 0 1 2 3 4
Reverse index:
Index: 0 -4 -3 -2 -1
Slicing:
Allows grabbing a subset of multiple characters, a slice of string.
Slicing syntax:
[start:stop:step]
Slicing syntax: Start is:
Numerical index for the slice start
Slicing syntax: Stop is:
Stop Index goes up to (but not include the last character)
Slicing syntax: Step is:
Size of the “jump” you take.
Does white space count as characters in strings:
Yes