def swap_case(s):
def tr(x):
if x.islower():
return x.upper()
elif x.isupper():
return x.lower()
else:
return x
result=''.join([tr(r) for r in list(s)])
return result
def swap_case(s):
def tr(x):
if x.islower():
return x.upper()
elif x.isupper():
return x.lower()
else:
return x
result=''.join([tr(r) for r in list(s)])
return result
本文标题:【hackrank】大小写互换
本文链接:https://www.haomeiwen.com/subject/ulwdnftx.html
网友评论