write a python program that reads a string and then prints a string that capitalizes every other letter in the string .
eg. Passion becomes pAsSiOn
1722:
kya laga bataa
kal bhi to bheja tha lyrics iska ....tab bhi bola tha acha song hai
topic bhi change krna ni ata tujeh to pagal hhahhaha
betiyan na palte betiyon ko marte ladkiyan pata ke unko bandi bolte hain
aur jo raazi na ho unko sale r***** bolte hain
Answers
Answered by
3
Here is ur answer mate:
def foo(s):
ret = ""
i = True # capitalize
for char in s:
if i:
ret += char.upper()
else:
ret += char.lower()
if char != ' ':
i = not i
return ret
>>> print foo("hello world")
HeLlO wOrLd'
Answered by
2
Here is ur answer mate:
def foo(s):
ret = ""
i = True # capitalize
for char in s:
if i:
ret += char.upper()
else:
ret += char.lower()
if char != ' ':
i = not i
return ret
Similar questions