将小写字符转换为大写字母和大写字母到小写字母

时间:2018-02-06 15:27:21

标签: python python-3.x

我想将给定字符串的小写字母转换为大写字母,将大写字母转换为小写字母。

例如:初始字符串: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():

0 个答案:

没有答案