Computer Science, asked by nivedithaja, 1 day ago

Write a program that reads a string and capitalizes every third word of the string.
Language: Python

Answers

Answered by ghanchiarsh466
0

Answer:

You can take a stride slice of an array which makes for a pretty and pythonic few lines:

s = "thisisareallylongstringwithlotsofletters" # convert to list a = list(s) #change every third letter in place with a list comprehension a[2::3] = [x.upper() for x in a[2::3]] #back to a string s = ''.join(a) # result: thIsiSarEalLylOngStrIngWitHloTsoFleTteRs

It's not clear what you want with 

Similar questions