0

dictonaries thing

pairs = {1: "apple", "orange": [2, 3, 4], True: "question", None: "True", } print(pairs.get(1)) why output is: question #not an 'apple'????

14th Dec 2016, 5:26 AM
Semen Dvachevsky
Semen Dvachevsky - avatar
3 Answers
+ 2
ok, i got it. key '1' and key 'True' - same key and program output last key.
14th Dec 2016, 5:35 AM
Semen Dvachevsky
Semen Dvachevsky - avatar
0
print(pairs.get(0)) >>> None >>> if it was an array result print(pairs.get(1)) will be: [2, 3, 4]
14th Dec 2016, 5:34 AM
Semen Dvachevsky
Semen Dvachevsky - avatar
- 1
array index starts from 0. to get apple, print(pairs.get(0));
14th Dec 2016, 5:28 AM
tazwar utshas
tazwar utshas - avatar