Back

Alternate Upper and Lower Case

Created 4 years ago
1119 Views
3 Comments
ChinmayRaval
@ChinmayRaval
ChinmayRaval
@ChinmayRavalProfile is locked. Login

# You are given a string ‘s’.Your task is to print the string in alternate lowercase and uppercase order.


# Input Description:# You are given a string
# Output Description:# Print the string according to given criteria
# Sample Input :# abcd efgh ijkl#

 Sample Output :# ABCD efgh IJKL


s=input("Enter a text here:")

s=s.split()

up=''"

lo=''"
for i in range(len(s)):    

if i%2==0:        

up+=s[i].upper()    

else:      

  lo+=s[i].lower()


print(up + " "+ lo)

The above code work fine for 2 words but while using more than 2 more alternate word mash up what should be done to solve this

Comments (3)
Please login to comment.