Question: Write a Python program that asks the user to input a string and then prints out that string in Title Case. That is, the first

Write a Python program that asks the user to input a string and then prints out that string in Title Case. That is, the first letter of each word is uppercase and the remainder of the word is lowercase. If the entire word is two letters long, the entire word is lower case. The three letter words and, the, and not are all lowercase while all other three letter words are capitalized. The first word in the string is capitalized. If the user enters the string the following strings:

The quick brown dog and the

the program should print out:

The Quick Brown Dog and the

So this is what I got:

Write a Python program that asks the user to input a string

I am not understanding how to do exceptions such as 'and', 'the', 'not'. Please teach me with source code(with comments) and provide output. Thanks

def what2capitalize (word): skipList = [ ' and ' , ' the ' , ' not ' ] if word not in skipList: return word.capitalize () return S = input ("Type in any string : ") print (s.title ())

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!