+ 2

pairs = {1: "apple", "orange": [2, 3, 4], True: False, None: "True", } print(pairs.get("orange")) print(pairs.get(1)) print(pairs.get(12345, "not in dictionary")) the output is [2, 3, 4] False not in dictionary why is print(pairs.get(13345,"not in dictionary")) giving the output not in dictionary.pls I nid explanation

10th Jan 2017, 2:32 PM
Ayaah Silas
4 odpowiedzi
+ 6
liste.get(something, else) if "something" is inside the list, you're asking the program to tell you what "something" is, however if it doesn't find "something", it will do whatever you put in the 'else' part. So in this case you're asking it to get [12345], but since it cannot find [12345] in the dictionary, it will print("not in dictionary")
10th Jan 2017, 9:46 PM
ramzi
ramzi - avatar
+ 2
It will print not in dictionary ... nothing else ... try again
14th Feb 2017, 3:04 AM
Himanshu
+ 1
if i got this right, you did not pushed the 12345 value in the dictionary before searching for it, so it is not there
10th Jan 2017, 8:58 PM
Igor Busquets
Igor Busquets - avatar
0
What do you mean 12345 in the question?
22nd Feb 2017, 10:05 AM
Michael
Michael - avatar