-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.py
46 lines (29 loc) · 1.01 KB
/
functions.py
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
35
36
37
38
39
40
41
42
43
44
45
46
'''Store your functions here'''
from random import choice
#Example functions
#Make sure function accepts only one list parameter
def upp(args) -> None :
'''Converts to uppercase. usage: $python3 cliutils.py upper "<Text here>"'''
res = ""
for i in args[0]:
res += i.upper() if "a" <= i <= "z" else i
print(res)
def lowe(args) -> None:
'''Converts to lowercase. usage: $python3 cliutils.py lower "<Text here>"'''
res = ""
for i in args[0]:
res += i.lower() if "A" <= i <= "Z" else i
print(res)
def invert(args) -> None:
'''Inverts input, usage : `$python3 cliutils.py invert "<Text here>"'''
print(args[0][::-1])
def randomcase(args):
'''converts input to randomcase. usage: `$python3 cliutils.py randomcase "<text here>"`'''
print(''.join(choice((str.upper, str.lower))(char) for char in args[0]))
#Add your function to the dict
func_dict = {
"upper":upp,
"lower":lowe,
"invert":invert,
"randomcase":randomcase
}