I’ve just done the Blossom project (Link), and as far as I can tell, I did it all correctly - it’s running without errors and it prints out the correct values for example keys at the end.
However, at the end it asks me to look up other flowers (I chose pansy) and how I would add them in, and I’m wondering how to do this? At first I thought, simple, just use the assign function. That didn’t work and I realised, well, it’s because the array has no more space (but we didn’t even implement a check for “nope, full!” so does that matter?), so I changed the instantiation to add one more. But it’s still printing out “None” as the value for “pansy”.
How do I add new flowers? (Other than adding them directly to flower_definitions?)
Edit: I’ve played around a bit with the size of the blossom instantiated hash map, and if I set it to 20 (as opposed to len(flower_definitions)), I get the correct values for daisy, sunflower and the manually added pansy. However, if I use values between 12 and 20, some or all of those start changing to None. I am so confused.
Edit 2: Found the problem (by checking everything against the walkthrough).
In the retrieve function, instead of
for item in list_at_index: if item == key: return item else: return None
I needed to do:
for item in list_at_index: if key == item: return item return None
I’ll never get right what needs to go inside a loop and what doesn’t…