Skip to content

Commit c05557a

Browse files
files
1 parent a1e2c7a commit c05557a

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import operator
2+
3+
def person_lister(f):
4+
def inner(people):
5+
return(map(f,sorted(people,key=lambda x:int(x[2]))))
6+
return inner
7+
8+
@person_lister
9+
def name_format(person):
10+
return ("Mr. " if person[3] == "M" else "Ms. ") + person[0] + " " + person[1]
11+
12+
if __name__ == '__main__':
13+
people = [input().split() for i in range(int(input()))]
14+
print(*name_format(people), sep='\n')
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Using decorators
2+
3+
def wrapper(f):
4+
def fun(l):
5+
f(["+91 "+c[-10:-5]+" "+c[-5:] for c in l])
6+
return fun
7+
8+
@wrapper
9+
def sort_phone(l):
10+
print(*sorted(l), sep='\n')
11+
12+
if __name__ == '__main__':
13+
l = [input() for _ in range(int(input()))]
14+
sort_phone(l)
15+
16+
# using closures
17+
def sort(lis):
18+
mob_lis=sorted(lis)
19+
def formated():
20+
for i in mob_lis:
21+
print("+91",i[:5],i[5:])
22+
return(formated)
23+
mob=[]
24+
for _ in range(int(input())):
25+
i=input()
26+
if len(i)!=10:
27+
if i.startswith("0"):
28+
mob.append(i.replace("0","",1))
29+
if i.startswith("91"):
30+
mob.append(i.replace("91","",1))
31+
if i.startswith("+91"):
32+
mob.append(i.replace("+91","",1))
33+
else:
34+
mob.append(i)
35+
mob_no=sort(mob)
36+
mob_no()
37+
38+

0 commit comments

Comments
 (0)