Question
In the context of this exercise, do these methods affect special characters?
Answer
No, the methods in this exercise, .lower()
.upper()
and .title()
will not affect special characters, which are any non-alphabetical and non-numeric characters. These methods will only apply to case-based characters, which include essentially all the alphabetical characters.
When applying these methods to strings with special characters, they will be treated similarly to how they apply to whitespace characters, which is also a type of special character, and one you might be familiar working with.
For example, here is how .title()
would work for a string with some special characters,
string = "hello-world#!"
titled = string.title()
print(titled) # Hello-World#!
As we can see, each word, separated by a special character, was capitalized.