Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
A user typed " ravi KUMAR ". What is its length? Tidy it with strip() and title(). What are the new text and the new length?
strip() removes the two ends. title() fixes the capital letters.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, compare your working with the solution.
The text has spaces, ravi, a space, KUMAR and spaces: characters.
strip() removes the spaces at the two ends, and title() makes the first letter of each word a capital letter and the rest small: Ravi Kumar. Its length is .
Log in to join the discussion.
Loading…