On this python project we are asked to combine two individual lists ‘toppings’ and ‘cost’ into a list of lists called ‘pizzas’. Then part of this problem is asking to use the function .count() on the single list ‘cost’ to count the number of times the number 2 is on such list. However, I was wondering if there was a way or another function similar to .count() that would let me count an occurrence from a list of lists.
single lists where i can use the function .count()
toppings = [ ‘pepperoni’, ‘pineapple’, ‘cheese’, ‘sausage’, ‘olives’, ‘anchovies’, ‘mushroom’]
cost = [2, 6, 1, 3, 2, 7, 2]
List of lists where the fuction .count() doesn’t work.
pizzas = [(1, ‘cheese’), (2, ‘mushroom’), (2, ‘olives’), (2, ‘pepperoni’), (3, ‘sausage’), (6, ‘pineapple’), (7, ‘anchovies’)]
Here is the link to the project
https://www.codecademy.com/paths/analyze-data-with-python/tracks/ida-2-introduction-to-python/modules/ida-2-3-python-lists/projects/lens-slice
Thanks,