0

python introduction course dictionary practice (collection types)

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 So i wrote print(ages["year") and I got only 1 of the 4 test cases correct so I was wondering how do I answer this question? I even tried using the ai they have but i can't access it and i cant see the other answers for the test cases either because I don't have the pro version unlocked - if anyone can help It would be very much appreciated

1st Oct 2023, 5:43 PM
yuujuckman
yuujuckman - avatar
2 Respostas
+ 1
There are two notes / 1 - You should take the key from the user as an input. 2 - You should save this input into a variable and access it (because the user might input 'brand' or 'year' or 'color')
1st Oct 2023, 6:00 PM
Omar Fahmy
Omar Fahmy - avatar
0
Double check the name of the dictionary you're calling on
1st Oct 2023, 5:49 PM
Aaron Lee
Aaron Lee - avatar