我想将给定字符串的小写字母转换为大写字母,将大写字母转换为小写字母。
例如:初始字符串:Hello World!
,结果输出必须为hELLO wORLD!
。
我目前的代码是:
# Ask the use to give a string
user_string = input("Please give a string: ")
new_string = user_string
# For each character in the given string
# Check if it is a capital letter and convert it to lower case.
# Check if it is a lower case letter and convert it to capital.
for char in user_string:
if char.islower():
new_string[char]=
if char.isupper():