-
Notifications
You must be signed in to change notification settings - Fork 0
/
directory-3.py
49 lines (33 loc) · 1.28 KB
/
directory-3.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
import database
def commandUser():
print()
command= input("To add a name and number to the directory; press the key 'a' \nTo find a name in the directory; press the key 'f' \nTo delete a name and number from the directory; press the key 'd' \nTo update a number in the directory; press the key 'u' \nTo quit the program; press the key 'q': ")
print()
command= command.lower()
#print (command)
return command
while True:
command = commandUser()
c= str(command)
if (c == 'a'):
key = input("Enter a name: ")
key= key.lower()
value = input("Enter the phone number(only enter digits): ")
value = int(value)
database.add("data.txt",key, value)
elif (c =='f'):
key = input("Enter the name you would like to search for: ")
key= key.lower()
database.find("data.txt", key)
elif (c == 'd'):
key = input("Enter the name you would like to delete: ")
key= key.lower()
database.delete("data.txt", key)
elif (c == 'u'):
key = input("Enter the name you would like to search for: ")
key= key.lower()
database.update("data.txt", key)
elif (c == 'q'):
break
else:
print ("Please enter a valid option.")