-
Notifications
You must be signed in to change notification settings - Fork 0
/
l2p5.py
55 lines (41 loc) · 1.1 KB
/
l2p5.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
47
48
49
50
51
52
53
54
55
# List-Program No : L2-P5
# Developed By : Vaibhav Bakshi
# Date : 12/01/21
C=['Delhi','Mumbai','Hyderabad']
def AddCity(C):
while True:
city = input('Enter The Name of The City')
C.append(city)
cont = input('Continue Adding Cities? (Y/N?)')
if cont in ['n','N']:
break
print('List is:\n', C)
def AllUCase(C):
T = []
for S in C:
T.append(S.upper())
print('Cities in List in UpperCase:\n',T)
def ShowDisp(C):
print('Cities in the list C are:\n', C)
def ShortNameCities(C):
T = []
for S in C:
if len(S) <= 4:
T.append(S)
print('Cities in list C with less than 4 Characters:\n', T)
def BigNameCities(C):
T = []
for S in C:
if len(S) > 4:
T.append(S)
print('Cities in list C with more than 4 characters:\n', T)
def CityNameLength(C):
print('Number of alphabets in each name of the city in list C:\n')
for S in C:
print('City:', S, 'Characters:', len(S))
AddCity(C)
AllUCase(C)
ShowDisp(C)
ShortNameCities(C)
BigNameCities(C)
CityNameLength(C)