Chapter 11 Assignment

I have been struggling with Chapter 11’s assignment for a week. I know how to sort the keys, but I cannot figure out how to make the names in the contact tuples. When I tried to use methods to add them into a list, I receive a ValueError and forces me to reload my page. Can anyone recommend a new approach or resources to understand dictionaries and tuples?

I can suggest that a technique might be to consider how to separate out the two elements of the value (where, in a dictionary, we have a key,value configuration). Can we use a variable to indicate the value, and do something with it that way?

1 Like

Okay, I think I have separated the two elements of the value now. I’m still struggling with how to combine the values and keys into a tuple. I end up running into TypeErrors.

If you think of a tuple just as three elements, separated with commas, you should be able to combine the three elements somehow to make that happen. Remember you have to assign the tuple to a variable.

1 Like

I think I’m slightly understanding tuple formation now. I was able to combine elements, but they all ended up in one tuple instead of a tuple per key-value pair. Also, each contact name is taking the first contact name’s information.

I was able to solve Ch. 11’s assignment! Seeing the tuple as elements separated with commas really helped. Accessing the values was hard for me, though. But, with help, I’m gradually getting a better understanding of how tuples and dictionaries work. Thank you for your help!

1 Like

So happy to hear that!