livepython.net

102. Python Program to Clean Up a Name with strip() and title()

EasyMethods

Overview

Use two string methods, one after the other, to tidy up what a user types.

Problem Statement

People type their names in all kinds of ways: with spaces at the ends, in capitals, or all small. Read a name, remove the spaces at both ends, give every word a capital first letter (and small letters after it), and print a greeting. For example, for sUNNY kumar :

Hello, Sunny Kumar!

Use input() with no prompt text: the tests type the input for you, and a prompt would end up in your output.

Input

One line with a name, maybe with spaces at the ends. Example (with three spaces before the name and two after it):

sUNNY kumar

Output

The output for that example:

Hello, Sunny Kumar!

The tests try 4 different inputs.

Learn this firstChapter 12 · Python String Methods: upper, strip, replace, find
solution.py
# write your code here

EXPECTED OUTPUT

1Hello, Sunny Kumar!

YOUR OUTPUT

Press Run to see your output here. Lines are compared with the expected output.