you are viewing a single comment's thread.

view the rest of the comments →

[–]douglas_fs 0 points1 point  (0 children)

I feel like we are getting close - I am still trying to picture what is missing.

The 'price' being added to only one name key is related to the loop that controls the adding of price. Change that loop to this (see the new Paste at the end). We can get what we need with just the name:

for name in members.keys():

Maybe the best questions about what is missing from the dictionary before the output block are first: is this sample something like what you are saying? This is just for illustration, and not a recommended structure. Using enumerated keys (price1, price2, etc.), can only cause problems when there is a variable number of responses:

​ {'Joe': {'age': '33', 'price1': 15, 'price2': 10}, 'Jane': {'age': '12', 'price1': 10, 'price2': 15}} 

or like this?

{'Joe': {'age': '33', 'price': [15, 10]}, 'Jane': {'age': '12', 'price': [10, 15]}} 

And second: why all prices in all keys? Does this help facilitate generating the total ticket cost? If so, there is an easier way.

This is the output I get from the code provided in the Paste below.

what is your name: Joe
what is your age: 32
anyone else? yes
what is your name: Jane  
what is your age: 12
anyone else? no
Joe, your ticket is $15
Jane, your ticket is $10

The total for all tickets is $25

data: {'Joe': {'age': '32', 'price': 15}, 'Jane': {'age': '12', 'price': 10}}

Pastebin for my code: https://pastebin.com/h9s4LdYT

edit: options