From ae4eb2283d03f58e9f429c234e0ee25a221fb6c8 Mon Sep 17 00:00:00 2001 From: Yakshith Rai M <106961136+Yakshithrai@users.noreply.github.com> Date: Sun, 27 Oct 2024 15:08:17 +0530 Subject: [PATCH] Added python program to toggle each character in a string --- Python/togglechar.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Python/togglechar.py diff --git a/Python/togglechar.py b/Python/togglechar.py new file mode 100644 index 000000000..91ded7458 --- /dev/null +++ b/Python/togglechar.py @@ -0,0 +1,17 @@ +#take user input +String = 'GuDDuBHaiyA' +#initialize other empty String +String1 = str() +#iterate through String +for i in String: + #check the case of each iterator + if i.isupper(): + #change it to opposit case + i = i.lower() + #Concat each iterator to String1 + String1 = String1 + i + else: + i = i.upper() + String1 = String1 + i +#print String1 +print(String + ' after changing ' + String1)