Takes a string and returns a copy of that string in which all lowercase letters are uppercase, and all upercase letters are lowercase. Numbers and symbols are not changed.
message = "Hello, World!"new_string = message.swapcase()print(new_string)# Output: "hELLO, wORLD!"
.swapcase() method does not change the string it is used on:
Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.
- Anonymous contributors
Learn Python on Codecademy
- Anonymous contributorsAnonymous contributors