String manipulation is useful in
for loops if you want to modify some content in a string.
word = "Marble" for char in word: print char,
The example above iterates through each character in
word and, in the end, prints out
M a r b l e.
, character after our
Let’s filter out the letter
"A" from our string.
- Do the following
character in the
print "X",instead of
char. Make sure to include the trailing comma.
- Otherwise (
print char,with the trailing comma.