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)


Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube