0
Using a dictionary key in a for loop or if statement
I want to use strings from a list to find keys in a dictionary so that I can return the associated value. This is what Iâve tried but my syntax is wrong: dict = {âfootâ:12.0, âcmâ:0.394, âyardâ:36.0} list = [âfootâ, âyardâ] for unit in list: for meas in dict: if unit == dict[meas][0]: Print(dict[meas][1]
4 RĂ©ponses
+ 1
Jan Markus what is the â_â after the names? Is it part of the syntax?
+ 1
Jan Markus thank you.
0
Jan Markus
I am still having trouble referencing the key in a dictionary. Below is my code for the Code Coach problem called Ballpark: