# [ ] review and run example
# the list before delete
sample_list = [11, 21, 13, 14, 51, 161, 117, 181]
print("sample_list before: ", sample_list)
del sample_list[1]
# the list after delete
print("sample_list after: ", sample_list)
# [ ] review and run example Multiple Times
# [ ] consider how to reset the list values?
print("sample_list before:", sample_list)
del sample_list[0]
print("sample_list after:", sample_list)
# [ ] review and run example
mixed_types = [1, "cat"]
# append number
mixed_types.append(3)
print("mixed_types list: ", mixed_types)
# append string
mixed_types.append("turtle")
print("mixed_types list: ", mixed_types)
# [ ] print ft_bones list
# [ ] delete "cuboid" from ft_bones
# [ ] reprint list
ft_bones = ["calcaneus", "talus", "cuboid", "navicular", "lateral cuneiform",
"intermediate cuneiform", "medial cuneiform"]
print(ft_bones)
del ft_bones[2]
print(ft_bones)
# [ ] print ft_bones list
# [ ] delete "cuboid" from ft_bones
# [ ] delete "navicular" from list
# [ ] reprint list
# [ ] check for deletion of "cuboid" and "navicular"
ft_bones = ["calcaneus", "talus", "cuboid", "navicular", "lateral cuneiform",
"intermediate cuneiform", "medial cuneiform"]
print(ft_bones)
del ft_bones[2]
del ft_bones[3]
print(ft_bones)
if ft_bones[2] == "cuboid":
print("3rd item not deleted")
else:
print("3rd item deleted")
# [ ] review and run example
# pop() gets the last item by default
party_list = ["Joana", "Alton", "Tobias"]
print(party_list)
print("Hello,", party_list.pop())
print("\n", party_list)
print("Hello,", party_list.pop())
print("\n", party_list)
print("Hello,", party_list.pop())
print("\n", party_list)
# [ ] review and run example
# can pop specific index like pop(3)
number_list = [11, 21, 13, 14, 51, 161, 117, 181]
print("before:", number_list)
number_list.pop(3)
print("after :", number_list)
# [ ] review and run example
# set a variable to a poped value
number_list = [11, 21, 13, 14, 51, 161, 117, 181]
print("list before:", number_list)
num_1 = number_list.pop()
num_2 = number_list.pop()
print("list after :", number_list)
print("add the popped values:", num_1, "+", num_2, "=", num_1 + num_2)
# [ ] pop() and print the first and last items from the ft_bones list
ft_bones = ["calcaneus", "talus", "cuboid", "navicular", "lateral cuneiform",
"intermediate cuneiform", "medial cuneiform"]
# [ ] print the remaining list
print(ft_bones.pop(0))
print(ft_bones.pop())
print(ft_bones)
dog_types = ["Lab", "Pug", "Poodle"]
while dog_types:
print(dog_types.pop())
#[ ] complete the Register Input task above
purchase_amounts = []
while True:
item_price = input("Enter the price of an item then type done when finished: ")
if item_price != 'done':
purchase_amounts += item_price
else:
print(purchase_amounts)
break
# [ ] complete the Register Total task above
purchase_amounts = []
while True:
item_price = input("Enter the price of an item then type done when finished: ")
if item_price != 'done':
purchase_amounts += item_price
else:
print(purchase_amounts)
break
subtotal = 0
while purchase_amounts != []:
float_price = float(purchase_amounts.pop())
subtotal += float_price
print(subtotal)
# [ ] review and run example
dog_types = ["Lab", "Pug", "Poodle"]
if "Pug" in dog_types:
dog_types.remove("Pug")
else:
print("no Pug found")
print(dog_types)
# [ ] review and run example
dogs = ["Lab", "Pug", "Poodle", "Poodle", "Pug", "Poodle"]
print(dogs)
while "Poodle" in dogs:
dogs.remove("Poodle")
print(dogs)
# [ ] review and run example
# Change to "Lab", etc... to fix error
dogs.remove("Collie")
print(dogs)
# [ ] remove one "Poodle" from the list: dogs , or print "no Poodle found"
# [ ] print list before and after
dogs = ["Lab", "Pug", "Poodle", "Poodle", "Pug", "Poodle"]
if "Poodle" in dogs:
dogs.remove("Poodle")
print(dogs)
else:
print("no Poodle found")