-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathCase Swapper.py
More file actions
34 lines (28 loc) · 898 Bytes
/
Case Swapper.py
File metadata and controls
34 lines (28 loc) · 898 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import pyperclip
"""
Program description :
Takes a string as input and creates an alternating upper and lower case pattern of the string. Eg : Hello becomes hELlO.
Note : The output is copied to clipboard. To do this, first => `pip install pyperclip`
"""
def caseswapper(value, choice):
if choice == "uppercase" or choice == "upper" or choice == "u":
j = 0
else:
j = 1
string = ""
for i in value:
if j % 2 == 0:
i = i.upper()
else:
i = i.lower()
j = j + 1
string = string + i
print(string)
pyperclip.copy(string)
print("The above string has been copied to your clipboard :)")
if __name__ == "__main__":
value = input("Enter a sentence \n> ")
choice = input(
"Do you want the first letter to in uppercase or lowercase? (U/L) \n> "
).lower()
caseswapper(value, choice)