Generate Alternate cases in String


Topic: Generate Alternate cases in String

Solution

test_str = "geeksforgeeks"
res = "" 
for idx in range(len(test_str)): 
    if not idx % 2 : 
       res = res + test_str[idx].upper() 
    else: 
       res = res + test_str[idx].lower() 
print(res)



List all Python Programs