Strings¶
Concepts¶
The string type
str:The minimal string
'',Indexing
[]Slicing
[:]Membership:
in(),not in())Inmutability property.
The string methods:
The
str.format()method (String_Formattig/index).String traversal
Keywords¶
# size
len()
# access and slice
s[i], s[2:7], s[2:10:2]
# membership
'a' in s, 'a' not in s, s1 in s,
# string methods
s.count('a'), s.replace('a', 'A'), s.isalpha(), ...
Examples¶
Notes¶
Slides¶
References¶
Section 4 in. Prof. Dolors Ayala, 2020.
How to Think Like a Computer Scientist: Learning with Python 2nd Edition.
Exercises¶
String Operations (operators, functions, methods)
Exercises¶
String traversal using for either over the str or over range(len(str).