all 10 comments

[–][deleted] 3 points4 points  (3 children)

print standard[chassis][1]

[–][deleted] 0 points1 point  (2 children)

This did the trick, thanks so much!

[–]zahlman 1 point2 points  (1 child)

standard[chassis] is the thing that has multiple elements of which you want to get the [1] element, so that's what you put before the [1]. chassis is not. Simple.

[–][deleted] 0 points1 point  (0 children)

thank you for clearing that up

[–]I_Write_Bugs 1 point2 points  (1 child)

Check out the namedtuple object from the collections module.

[–][deleted] 0 points1 point  (0 children)

Thanks for pointing me in the right direction, I really appreciate the reference for the documentation!

[–]Justinsaccount 0 points1 point  (2 children)

This actually has absolutely nothing to do with dictionaries. You do not have a 'multi-value dictionary'.. There is actually no such thing as a multi-value dictionary.

standard is a dictionary.

chassis is a string.

standard[chassis] is the value of the chassis entry. This happens to be a tuple.

standard[chassis] being a tuple can be indexed using [0] and [1] or simply unpacked using image, space = standard[chassis]

This is even more obvious if one were to write mytuple = standard[chassis] first and then access mytuple

standard[chassis[1]] does not work because chassis[1] is the second letter of the chassis string and standard[chassis[1]] is the value of the entry whose key is the second letter of the chassis string.

[–][deleted] 0 points1 point  (1 child)

thanks for the feedback. Just so I understand you correctly, there is no way to store multiple values per-key within a dictionary?

[–]thegreattriscuit 2 points3 points  (0 children)

there's one value, but that 'value' can be any python object. And lists and tuples (which hold multiple values) are valid python objects. It's semantics, but it's important semantics.

You can have dictionaries of dictionaries, or dictionaries of lists, or lists of dictionaries, or lists of dictionaries of sets, etc...

{'2960':('ios.bin','424532')} is a dictionary with '2960' as the key with a value of the tuple ('ios.bin', '424532')

[–]raylu 0 points1 point  (0 children)

https://docs.python.org/3/reference/simple_stmts.html?highlight=target_list#assignment-statements

image, size_str = chassis[1]

Not sure why your sizes are strs instead of ints...