题目:将输入中的英文字符,大写改成小写,小写改成大写
思路一:
while True:
try:
s = input()
low = 'abcdefghijklmnopqrstuvwxyz'
up = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ns = ''
for c in s:
if c in low:
ns += c.upper()
elif c in up:
ns += c.lower()
else:
ns += c
print(ns)
except:
break
思路二:
用python内置函数
while True:
try:
s = input()
print(s.swapcase())
except:
break