Reputation: 67
I know how to solve this problem using multiple lines but in the spirit of clean code is there a way to run multiple string functions in the same line?
Essentially I'm returning a string using
''.join(string.title())
after I need to remove whitespaces from the new modified string:
string.replace(" ", '')
The whitespace is important at the beginning as it allows me to use the title function so the order shouldn't change.
Upvotes: 1
Views: 8132
Reputation: 1097
You can add together string functions like this:
''.join(string.title()).replace(" ", '')
Hope this helps you.
Upvotes: 4