1文字ずつ、大文字は小文字に、小文字は大文字にして出力せよという問題
pythonにはそれができる関数があるので
print(input().swapcase())
これにて終わりですが、もしその関数がなかったらどう実装するか。
ひとまずその1文字ずつ切り出して大文字か小文字かを調べて変換するというのが考えられる。
1文字ずつ切り出す方法は以前やった。
小文字かを調べるのはislower()
他にもisupper()
,istitle()
がある。
s = input()
for character in s:
if character.islower():
print(character.upper(), end="")
else:
print(character.lower(), end="")
print()