HackerRank- Python Swap Case



Given a string and your task is to swap cases. In other words, convert all lowercase letters to uppercase letters and vice versa.



  1. def swap_case(s):
  2. x = ""
  3. for let in s:
  4. if let.isupper() == True:
  5. x+=(let.lower())
  6. else:
  7. x+=(let.upper())
  8. return x
  9. if __name__ == '__main__':
  10. s = input()
  11. result = swap_case(s)
  12. print(result)

download android app