Avatar ·

Make the first letter of each word uppercase (capital)

📁 Advanced Python Topics

Let's say I have a string:

stroka = input()

Input data:

qwertyu iopasd fghjklz xcvbnm

How can I make it so that all words in the output start with a capital letter?

Qwertyu Iopasd Fghjklz Xcvbnm

Not just one word after a period, but all words in the string.

Avatar ·
In [20]: import reIn [21]: task = ""D11i14V17A8n7R11H16r18P18E5h18i18x8O16Y5s13d1X6u4a20C2p2O14J5I11L5K6y4X19n10s17h1E17Q5Z1U1K6    ...: U8E8L11n14k6""In [22]: numbers, lit = list(re.findall(r'\\d+', task)), list(re.findall(r'\\D', task))In [23]: ''.join(int(x) * y for x, y in zip(numbers, lit))

Result:

Out[25]:                                 

Log in to leave an answer

Blogs