Write a function called "swap" that takes a string as input, and returns a new
string with lowercase changed to uppercase, uppercase changed to lowercase.
虽然很丑
但经过我的努力
我可以把大写小写对调
但是为什么都跑到第二个字母就停了
def swap(string):
for index in range(0, len(string)):
for index2 in range(0, len(string)):
if (
string[index] == string[index].upper()
and string[index2] == string[index2].lower()
):
newstring = string[index].lower() + string[index2].upper()
print("newstring")
return "newstring"
swap("Aloha")
# returns "aLOHA"
swap("Love you.")
# returns "lOVE YOU."
但returns实际长这样
aL
lO