Nauč se Python > Kurzy > Beginners course PyLadies > Strings > Strings

Strings – Řešení [2]

name = input('Enter your name: ')
surname = input('Enter your surname: ')
initials = name[0] + surname[0]
print('Initials:', initials.upper())

There are more ways how to write such a program. You can call upper() twice - on name and surname separately.

Or like this:

name = input('Enter your name: ')
surname = input('Enter your surname: ')
print('Initials:', (name[0] + surname[0]).upper())

I recommend the first option. It is longer but way more clear.


Toto je stránka lekce z kurzu, který probíhá nebo proběhl naživo s instruktorem.