+ 1

How do i call multiple value from a dictionary?

27th Feb 2019, 9:50 PM
Sunday Afolabi
Sunday Afolabi - avatar
9 Réponses
+ 6
What do you mean exactly? Dictionaries are basically key-value pairs, how do you want to "call multiple values" there?
27th Feb 2019, 10:31 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 4
a = {1:"a",2:"b"} b = "12" s = "".join([a[int(i)] for i in b]) print(s)
28th Feb 2019, 5:24 AM
Nathan Lewis
Nathan Lewis - avatar
+ 2
Explain what you are trying to do in your code
27th Feb 2019, 10:30 PM
Nathan Lewis
Nathan Lewis - avatar
+ 2
{1:a, 2:b 3:c} And input is '12' how do i output ab' together?
28th Feb 2019, 5:14 AM
Sunday Afolabi
Sunday Afolabi - avatar
+ 2
d = {1:"a",2:"b"} s = "" for i in d: s += d[i] print(s)
28th Feb 2019, 5:33 AM
sumito_hz
sumito_hz - avatar
+ 2
In my example, change variable b to b = int(input("Enter your number")) or str(input("Enter your number")), whatever your dict key type is
28th Feb 2019, 6:02 AM
Nathan Lewis
Nathan Lewis - avatar
+ 1
code={ '1' : 'a', '2' : 'b', '3' : 'c', } s = "" aske=input("enter you number ") for aske in code: s += code[aske] print(s) #i want this code to print out the value of two or more numbers when enteered
28th Feb 2019, 6:00 AM
Sunday Afolabi
Sunday Afolabi - avatar
+ 1
d = {'1':'a','2':'b','3':'c'} s = '' ask = list(input('enter your number')) for i in ask: s += d[i] print(s)
28th Feb 2019, 6:25 AM
sumito_hz
sumito_hz - avatar
0
Contribute guys
27th Feb 2019, 9:50 PM
Sunday Afolabi
Sunday Afolabi - avatar