+ 1
Python intermediate help with dictionaries
I need help with the question “assign all data in the book dictionary to the into variable”. I got as far as info=book.______ and I don’t know what to put in the blank slot. Please help!! Tried to google and can’t find anything
10 Risposte
+ 2
which one is this?
course: python intermediate
lesson: ?
lecture: ?
+ 2
Gillian ,
in your initial task description you are talking about `data`, now you mention `values`.
to assign all `values` of a dictionary to a variable, we can use the dictionary method .values()
but as far as i remember this exercise, we should assign all data, that means `keys and values`. this requires the dictionary method .items()
+ 2
Willam Abroy ,
the task is:
>> assign all data (keys and values) in the book dictionary to the into variable.
when using .get(), we need to give an argument (*key*)
syntax:
dict.get(key, default_value)
key: the key to look up / find
default_value [optional]: value to return if the key is not found.
in the given case we do not know the keys, so using get() doesn't seem to be a suitable solution.
maybe you can give us a code sample to demonstrate your solution. thanks.
+ 1
Lothar thank you so much! This helped me complete the question
0
Its from python intermediate course, i think working with dictionaries lesson
0
course: python intermediate
module: collection types
lesson: dictionaries / dictionary functions
does not contain that.
there is no lesson: working with dictionaries in the entire course.
so please, find it that any of us may help you....
thanks
0
I am not sure how to specify it more. I am looking at the lesson called “working with dictionaries” right now. I would go into it to find the specific question but i don’t have hearts right now. Can you help me by telling me how to assign all data in a dictionary to a new variable? What is the function for that. It uses dot. Notation
0
that's in: python developer course.
I just restarted that course in the near past, so now I can't see the task :(
0
Do you know how to assign all values in a dictionary to a new variable?
0
try .items