+ 3

Is it possible to use words and numbers as a value in a Python dictionary?

Python dictionary

25th Oct 2020, 7:14 PM
Reacy.Py
Reacy.Py - avatar
8 Respuestas
+ 3
Thanks again Jan Markus for all your help, this is what I was working on... Just wanted to practice some of the things I've recently learned! https://code.sololearn.com/cwHt6bRfPWFY/?ref=app
25th Oct 2020, 10:40 PM
Reacy.Py
Reacy.Py - avatar
+ 2
Whenever I try to assign a value it's not accepting the words, it only accepts the numbers I put in the value field...
25th Oct 2020, 7:29 PM
Reacy.Py
Reacy.Py - avatar
25th Oct 2020, 7:37 PM
Reacy.Py
Reacy.Py - avatar
+ 2
That's a snippet of what I'm trying to do
25th Oct 2020, 7:38 PM
Reacy.Py
Reacy.Py - avatar
+ 2
The Keys are working fine, it's the values that don't seem to come out the way I'm expecting...
25th Oct 2020, 7:40 PM
Reacy.Py
Reacy.Py - avatar
+ 2
Oooooohhhhhh, silly me! Thanks!.!.!
25th Oct 2020, 7:44 PM
Reacy.Py
Reacy.Py - avatar
0
Why don't you test that on the python IDE. e.g write the code below and see what happens. If no error then its possible. d = {'first': 1, 'second':2, 1:'first', 3:'third'} print(d)
25th Oct 2020, 7:35 PM
Mawande Mbudane
Mawande Mbudane - avatar
0
Absolutely! With number keys as well as values. Same as with words(strings) . Beauty of python dictionary👌
26th Oct 2020, 9:21 AM
Naseem Ullah
Naseem Ullah - avatar