Give an example of swapcase( ) in Python
Answers
Answered by
1
Answer:
Python string | swapcase() The string swapcase() method converts all uppercase characters to lowercase and vice versa of the given string, and returns it. Here string_name is the string whose cases are to be swapped.
Answered by
0
Example of swapcase( ) in Python
Explanation:
The swapcase() string method converts, and returns, all uppercase characters to lowercase and every one lowercase character to uppercase character of the required string.
- Syntax - str.swapcase()
- Parameters - The swapcase() method requires no parameters in the least.
- Return Value - This method returns a replica of the string during which all characters supported the case had their case swapped.
The following example shows the usage of swapcase() method:-
- string = "PythonSwapCase"
- print(string.swapcase())
- string = "striver"
- print(string.swapcase())
- Output:
- pYTHONsWAPcASE
- STRIVER
Similar questions
Science,
5 months ago
Math,
5 months ago
Computer Science,
11 months ago
Computer Science,
11 months ago