Skip to content

Commit 0974c93

Browse files
author
meshmote
committed
Added action UWPCE-PythonCert#3 code
1 parent 7dd833e commit 0974c93

1 file changed

Lines changed: 30 additions & 1 deletion

File tree

‎Students/RPerkins/session03/listlab.py‎

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2+
#action #1
13
basket = ["Apples", "Pears", "Oranges", "Peaches"]
24
print basket
35
new_fruit = raw_input('Type in the name of another fruit-->')
@@ -18,6 +20,33 @@
1820
for i in range(len(basket)):
1921
if basket[i][0] == "P":
2022
print basket[i]
23+
24+
#action 2
2125
print basket
2226
basket.pop()
23-
print basket
27+
print basket
28+
del_fruit = raw_input("Pick a fruit from the list to delete-->")
29+
fruit = str(del_fruit)
30+
if fruit in basket:
31+
for i in range(len(basket)):
32+
if basket[i] == fruit:
33+
basket.pop(i)
34+
else:
35+
print 'That fruit is not in the basket'
36+
37+
#action 3
38+
deletes = 0
39+
for i in range(len(basket)):
40+
i = i - deletes
41+
lfruit = None
42+
while not (lfruit == "yes" or lfruit == "no"):
43+
like_fruit = raw_input("Do you like %s-->" % basket[i].lower())
44+
lfruit = str(like_fruit)
45+
if lfruit == 'no':
46+
basket.pop(i)
47+
deletes += 1
48+
print basket
49+
50+
51+
52+

0 commit comments

Comments
 (0)