Stuck on Task 5 “Clean Up” in Tisbury Treasure Hunt

Hey there!

My name’s Henry and I’m currently stumped on the final task of “Tisbury Treasure Hunt”.

The thing is: I don’t really know where to start on this one. Here’s what I understood so far:

  • The basic task: compare the items in the tuple with each other and throw out any information that is in there more than once (i.e. the coordinates, which are always twice).

  • The task wants me to use for (for-)loops to iterate over the nested tuples.

Here’s what stumped me:

  • I don’t know where to start since having three brackets for two nested tuples makes it kind of hard to know how to build a proper loop to iterate over the “correct” tuple.

  • While I do know how to compare items of tuples, I also know that Tuples are immutable, making it impossible to “throw out” singular items as well as simply creating a new tuple and adding in all the necessary information while iterating over a tuple (compared to adding items to an “empty list”).

Is there any way to help me popping the knot in my brain? Please don’t just give me the solution, I am genuinley trying to solve this my own way instead of just copying an answer. :sweat_smile:

1 Like

Hi Henry, :wave:

This one is sorta hard to hint at, so I am going to go with one directive, and one hint.

  1. Hint: We are not asking you to compare anything here. Rather, we are asking you to extract information and build results from it.

  2. All the information and techniques you need to complete this task were covered in the introduction to the exercise, or in the introductions of exercises that come before this exercise. The nested nature of the input is a bit of a Red Herring for looping. If you loop over the input data, you will get the following:

>>> input_data = (
...                 ('Scrimshawed Whale Tooth', '2A', 'Deserted Docks', ('2', 'A'), 'Blue'),
...                 ('Brass Spyglass', '4B', 'Abandoned Lighthouse', ('4', 'B'), 'Blue'),
...                 ('Robot Parrot', '1C', 'Seaside Cottages', ('1', 'C'), 'Blue'),
...                 ('Glass Starfish', '6D', 'Tangled Seaweed Patch', ('6', 'D'), 'Orange'),
...                 ('Vintage Pirate Hat', '7E', 'Quiet Inlet (Island of Mystery)', ('7', 'E'), 'Orange'),
...                 ('Pirate Flag', '7F', 'Windswept Hilltop (Island of Mystery)', ('7', 'F'), 'Orange'),
...                 ('Crystal Crab', '6A', 'Old Schooner', ('6', 'A'), 'Purple'),
...                 ('Model Ship in Large Bottle', '8A', 'Harbor Managers Office', ('8', 'A'), 'Purple'),
...                 ('Angry Monkey Figurine', '5B', 'Stormy Breakwater', ('5', 'B'), 'Purple'),
...                 ('Carved Wooden Elephant', '8C', 'Foggy Seacave', ('8', 'C'), 'Purple'),
...                 ('Amethyst  Octopus', '1F', 'Aqua Lagoon (Island of Mystery)', ('1', 'F'), 'Yellow'),
...                 ('Antique Glass Fishnet Float', '3D', 'Spiky Rocks', ('3', 'D'), 'Yellow'),
...                 ('Silver Seahorse', '4E', 'Hidden Spring (Island of Mystery)', ('4', 'E'), 'Yellow')
...         )
>>>
>>> for item in input_data:
...   print(item)
...
('Scrimshawed Whale Tooth', '2A', 'Deserted Docks', ('2', 'A'), 'Blue')
('Brass Spyglass', '4B', 'Abandoned Lighthouse', ('4', 'B'), 'Blue')
('Robot Parrot', '1C', 'Seaside Cottages', ('1', 'C'), 'Blue')
('Glass Starfish', '6D', 'Tangled Seaweed Patch', ('6', 'D'), 'Orange')
('Vintage Pirate Hat', '7E', 'Quiet Inlet (Island of Mystery)', ('7', 'E'), 'Orange')
('Pirate Flag', '7F', 'Windswept Hilltop (Island of Mystery)', ('7', 'F'), 'Orange')
('Crystal Crab', '6A', 'Old Schooner', ('6', 'A'), 'Purple')
('Model Ship in Large Bottle', '8A', 'Harbor Managers Office', ('8', 'A'), 'Purple')
('Angry Monkey Figurine', '5B', 'Stormy Breakwater', ('5', 'B'), 'Purple')
('Carved Wooden Elephant', '8C', 'Foggy Seacave', ('8', 'C'), 'Purple')
('Amethyst  Octopus', '1F', 'Aqua Lagoon (Island of Mystery)', ('1', 'F'), 'Yellow')
('Antique Glass Fishnet Float', '3D', 'Spiky Rocks', ('3', 'D'), 'Yellow')
('Silver Seahorse', '4E', 'Hidden Spring (Island of Mystery)', ('4', 'E'), 'Yellow')

Now, the questions are

  • What do you need to do inside that loop to extract the information you need to build results?
  • How/where would you build those results?

Hope that helps, and doesn’t give too much away. Let me know how I did…:sweat_smile:

Edited to add: link to the hints file for this exercise

2 Likes

@BethanyG I didn’t have a chance to fully commit myself to this task again yet, but the hint alone is pure gold and helped me to fully grasp where to start, where my train of thought went off-track and how to tackle the challenge. Thank you very much!! :raised_hands:

1 Like