- 3

Dictionary

You are working at a car dealership and store the car data in a dictionary: car = { 'brand': 'BMW', 'year': 2018, 'color': 'red' } Your program needs to take the key as input and output the corresponding value. Sample Input: year Sample Output: 2018

19th Mar 2021, 6:29 AM
Kathiravan P
Kathiravan P - avatar
10 Respostas
+ 5
#simple car = { 'brand':'BMW', 'year': 2018, 'color': 'red', 'mileage': 15000 } key= input() print(car[key])
5th Apr 2021, 5:53 AM
Allan đŸ”„STORMERđŸ”„đŸ”„đŸ”„đŸ”„
Allan đŸ”„STORMERđŸ”„đŸ”„đŸ”„đŸ”„ - avatar
+ 1
Take an input which should match the key and then call the get() on the dictionary by passing that key. Eg- car.get('year')
19th Mar 2021, 6:47 AM
Avinesh
Avinesh - avatar
+ 1
Your program needs to take the key as input and output the corresponding value. #① 需芁 氆 key䜜äžș(=) input()èŸ“ć…„ć‡œæ•° 的 ć˜é‡ïŒŒ #② 然搎氆歗慞 car 撌 揘量key ïŒŒæ‰“ć° ć‡ș盾ćș”çš„ć€Œă€‚ïŒ‰ car = { 'brand':'BMW', 'year': 2018, 'color': 'red', 'mileage': 15000 } key= input() #① print(car[key]) #② tq Allan QBit
5th Apr 2021, 11:04 PM
LEE KWANG PHENG
LEE KWANG PHENG - avatar
+ 1
car = { 'brand':'BMW', 'year': 2018, 'color': 'red', 'mileage': 15000 } key=input() if key in car : print(car.get(key))
25th Jul 2021, 3:41 PM
Asbibi
Asbibi - avatar
0
print(car['brand']) you can call it from dictionary using its key
30th Mar 2021, 4:44 PM
mohamad bilal
mohamad bilal - avatar
0
car = { 'brand':'BMW', 'year': 2018, 'color': 'red', 'mileage': 15000 } key= input() print(car[key])
9th Apr 2021, 12:49 PM
Anas Emad
0
car = { 'brand': 'BMW', 'year': 2018, 'color': 'red' } data = input("Enter the key: ") print(car[data])
22nd Nov 2021, 7:50 PM
Mohammad Jamal Mahmoud Al Jadallah
Mohammad Jamal Mahmoud Al Jadallah - avatar
0
car = { 'brand':'BMW', 'year': 2018, 'color': 'red', 'mileage': 15000 } key= input() print(car[key])
29th Nov 2021, 3:48 PM
Danish Al Muqri
0
#simple car = { 'brand':'BMW', 'year': 2018, 'color': 'red', 'mileage': 15000 } key= input() print(car[key])
16th Dec 2021, 5:36 AM
Md. Rakibul Islam
Md. Rakibul Islam - avatar
0
car = { 'brand':'BMW', 'year': 2018, 'color': 'red', 'mileage': 15000 } key = input("Enter the key: ") print(car[key])
5th Oct 2023, 1:55 PM
Elham Mohammad