-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMayorBook.py
More file actions
59 lines (46 loc) · 1.85 KB
/
MayorBook.py
File metadata and controls
59 lines (46 loc) · 1.85 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
#Simple searchable addressbook in python
print("""
\t ---------------------Welcome to Mayor's Book----------------------
\t
\t--------------------------------------------------------------------
""")
def displayuserinfo (userinfo):
print("\t---------------------------------")
print("\t!! Match found for ", userinfo[0], "", userinfo[1], "!!")
print("\tFirst Name: ", userinfo[0])
print("\tLast Name: ", userinfo[1])
print("\tAddress: ", userinfo[2])
print("\tEmail: ", userinfo[3])
print("\tPhone No.: ", userinfo[4])
print("\tWork Phno.: ", userinfo[5])
print("\t---------------------------------")
return
firstname=""
lastname=""
entryfound=""
#-------------------Getting User Input--------------------------
while firstname!="quit":
firstname=input("Enter your First Name (quit to exit):")
firstname=firstname.lower()
if firstname=="quit":
break
else:
lastname=input("Enter your Last Name:")
lastname=lastname.lower()
#--------------------Checkadress Book-----------------------------
addressbook=open("C:/Users/Pankhuri Trikha/Documents/MayorBook.txt",'r')
for line in addressbook:
userinfo=line.split("|")
if((userinfo[0].lower()==(firstname or firstname.lower)) and (userinfo[1].lower()==(lastname or lastname.lower))):
entryfound=True
break
else:
entryfound=False
continue
#------------------Display Data---------------------------------
if entryfound==False:
print("Sorry !! The firstname and lastname doesn't exists")
else:
displayuserinfo(userinfo)
addressbook.close()
entryfound=""