FAQ: Collections - Review of Specialized Containers

This community-built FAQ covers the “Review of Specialized Containers” exercise from the lesson “Collections”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn Intermediate Python 3

FAQs on the exercise Review of Specialized Containers

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!
You can also find further discussion and get answers to your questions over in #get-help.

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head to #get-help and #community:tips-and-resources. If you are wanting feedback or inspiration for a project, check out #project.

Looking for motivation to keep learning? Join our wider discussions in #community

Learn more about how to use this guide.

Found a bug? Report it online, or post in #community:Codecademy-Bug-Reporting

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

I’m doing the final part of the lesson of the collections. This is my code:

from collections import deque, namedtuple

overstock_items = [['shirt_103985', 15.99],

                    ['pants_906841', 19.99],

                    ['pants_765321', 15.99],

                    ['shoes_948059', 29.99],

                    ['shoes_356864', 9.99],

                    ['shirt_865327', 10.99],

                    ['shorts_086853', 9.99],

                    ['pants_267953', 21.99],

                    ['dress_976264', 32.99],

                    ['shoes_135786', 17.99],

                    ['skirt_196543', 12.99],

                    ['jacket_976535', 26.99],

                    ['pants_086367', 30.99],

                    ['dress_357896', 29.99],

                    ['shoes_157895', 14.99]]

# Write your code below!

split_prices = deque()

ClothesBundle = namedtuple("ClothesBundle", ["bundle_items", "bundle_price"])

bundles = []

promoted_bundles = []

# sorting prices in split_prices

for item in overstock_items:

  if item[-1] > 20:

    split_prices.appendleft(item)

  else:

    split_prices.append(item)

# loop to make bundles

while len(split_prices) >= 5:

  price = 0

  items = []

  for i in range(3):

    t_price = split_prices.pop()

    items.append(t_price[0])

    price += t_price[-1]

  for i in range(2):

    t_price = split_prices.popleft()

    items.append(t_price[0])

    price += t_price[-1]

  bundles.append(ClothesBundle(items, price))

# check if bundle is over $100

for bundle in bundles:

  if bundle.bundle_price > 100:

    promoted_bundles.append(bundle)

# printing the result

print(promoted_bundles)

for bundle in promoted_bundles:

  print(bundle)

Whenever I run this code on the last step I get the error: Did you print out promoted_bundles? When I’m clearly printing out the promoted bundles. I’ll have to copy the solution to progress, but could any of you tell if my code is wrong?

This is the link to the lesson: https://www.codecademy.com/courses/learn-intermediate-python-3/lessons/collections-python/exercises/review-of-specialized-containers-python