Dictionaries


#1

i am learning dictionaries right now i there any habit or preconception of what to chose as key or value??


#2

Your reason for using a dict is typically going to dictate this for you.
For example, if it’s phone numbers you might have name->phonenumber phone_directory = {'bob': '123'}

But that somehow isn’t the case, then you’d probably name them same way as variables, which is by what the value represents. So if you asked your user for their name, then you might use a variable named “name”


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.