-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathString Swap Cases.py
More file actions
70 lines (59 loc) · 1.41 KB
/
String Swap Cases.py
File metadata and controls
70 lines (59 loc) · 1.41 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
def convert_to_upper(string):
new = " "
for i in string:
j = ord(i) - 32
if 97 <= ord(i) <= 122:
new = new + chr(j)
else:
new += i
print(new + '\n')
def convert_to_lower(string):
new = " "
for i in string:
j = ord(i) + 32
if 65 <= ord(i) <= 90:
new = new + chr(j)
else:
new += i
print(new + '\n')
def Input(option):
print(String)
num = int(input("*"))
if num == 1:
convert_to_upper(input("Enter the string: \n"))
Input(String)
elif num == 2:
convert_to_lower(input("Enter the string: \n"))
Input(String)
elif num == 3:
a = input("Enter the string: \n")
convert_to_upper(a)
convert_to_lower(a)
Input(String)
else:
print('Wrong Input...Try again! \n')
Input(String)
String = 'Select any Option: \n 1.Uppercase\n 2.Lowercase\n 3.Both\n'
Input(String)
'''
#upper to lower
string = input("Enter the string: ")
new = ' '
for i in string:
if 65<=ord(i)<=90:
i = ord(i) + 32
new = new + chr(i)
else:
new += i
print(new)
#lower to upper
string = input("Enter the string: ")
new = ' '
for i in string:
if 97<=ord(i)<=122:
i = ord(i) - 32
new = new + chr(i)
else:
new += i
print(new)
'''