A string (only alphabets) is passed as input.
The printed output should contain alphabets in odd positions in each word in uppercase and alphabets in even positions in a word in lowercase.
Example input/output1:
If the input is 'tREE GiVES us fruiTS', the output should be 'TrEe GiVeS Us FrUiTs
If the input is 'FLoweR iS beauTIFUL', the output should be 'FlOwEr Is BeAuTiFuL'
Solution:
s=list(input().split())
for i in range(len(s)):
t=""
for j in range(len(s[i])):
if j%2!=0:
t+=s[i][j].lower()
else:
t+=s[i][j].upper()
s[i]=t
for i in s:print(i,end=" ")
No comments:
Post a Comment