-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram5.py
More file actions
47 lines (34 loc) · 935 Bytes
/
program5.py
File metadata and controls
47 lines (34 loc) · 935 Bytes
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
def addToList(l,item):
l.append(item)
def deletFromList(l,item):
l.remove(item)
def printList(l):
for item in l:
print(item)
def findElement(l,item):
if item in l:
print("Item found at index {} ".format(l.index(item)))
else:
print("Item not found")
shopping_list = []
while(True):
print(" 1. Add ")
print(" 2. Delete ")
print(" 3. Print List")
print(" 4. Find Item ")
print("-1 to exit")
choice = int(input("What you want to do ? "))
if(choice == -1):
break
if(choice == 1):
item = input("Enter item :")
addToList(shopping_list,item)
if(choice == 2):
item = input("Enter item :")
deletFromList(shopping_list,item)
if(choice == 3):
print("Shopping list is :")
printList(shopping_list)
if(choice == 4):
item = input("Enter item :")
findElement(shopping_list,item)