Advertisement
ganiyuisholaafeez

Cases Method

Feb 19th, 2020
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. """ The function converts a string in a particular case
  2. to another case entirely using different case methods"""
  3. # The function accept a string argument
  4. def up_and_down(string):
  5.  
  6. # Defining three different cases
  7.     case = string.lower() # Converts to lowercase provided it is not in lowercase
  8.     case = string.capitalize() # Converts to UPPER case provided it is not in uppercase
  9.     case = string.swapcase() # Converts to MiXEd case provided it is not in mixed case
  10.  
  11. # Return converted cases
  12.     return case
  13.    
  14. # Function Invokation
  15. print(up_and_down("HELLO"))
  16. print(up_and_down("genius"))
  17. print(up_and_down("ESPreSso"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement