Python > Assignment #2: Catalogue
Deadline: Tue 04. 10. 2016, 07:47 CET
Assignment [2pts]: Write a short script that prompts the user for a name, and then transforms the supplied name into a form used for filing, consisting of:
- the surname, in all-caps
- command and space
- the first name, capitalized
Name: tomas kuzma
Filed as: KUZMA, Tomas
Name: saMOT AmzuK
Filed as: AMZUK, Samot
Solution:
line = input('Name: ')
words = line.split()
first = words[0].title()
last = words[1].upper()
print('Filed as: ' + last + ', ' + first)
Bonus [1pts]: Make the script handle multiple “first” names correctly, that is output them properly capitalized in the original order.
Name: to mas kuzma
Filed as: KUZMA, To Mas
Solution