We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
def swap_case(s):
lst=[]
for i in s:
if i.isupper():
lst.append(i.lower())
else:
lst.append(i.capitalize())
return ''.join(lst)
if name == 'main':
it is a simplest way to solve the problem...
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
sWAP cASE
You are viewing a single comment's thread. Return to all comments →
def swap_case(s): lst=[] for i in s: if i.isupper(): lst.append(i.lower()) else: lst.append(i.capitalize()) return ''.join(lst) if name == 'main': it is a simplest way to solve the problem...