0

Trying to solve car data dictionary intermediate python challenge

SoRRY ABOUT THE CAPS BUT MY DEVICE WONT TURN OFF THE CAPS HERE IS THE CODE THAT I USED user_input=input() try: car = { 'brand':'BMW', 'year': 2018, 'color': 'red', 'mileage': 5000 } print(car[user_input]); except KeyError: print("There is no such car as", "'" + user_input + "'", "in the dictionary!") It PASSES ON 4 OUT 5 TEST CASES AND WHAT SHOULD I DO?

13th Feb 2021, 6:39 AM
Kim Hammar-Milliner
Kim Hammar-Milliner - avatar
10 Answers
+ 4
I can't find the challenge but I noticed something, in the challenge, the given dictionary is car = { 'brand': 'BMW', 'year': 2018, 'color': 'red' } But in your code, it has an other key "mileage". car = { 'brand':'BMW', 'year': 2018, 'color': 'red', 'mileage': 5000 } EDIT: The problem is with the value of mileage, it should be 15000 and not 5000.
13th Feb 2021, 7:18 AM
noteve
noteve - avatar
+ 4
Kim Hammar-Milliner It's 15000 not 5000 car = { 'brand':'BMW', 'year': 2018, 'color': 'red', 'mileage': 15000 } print(car[input()])
13th Feb 2021, 7:33 AM
noteve
noteve - avatar
+ 1
Downvote if I am wrong because I am not understanding the problem but here is my approach, try this out https://code.sololearn.com/c8axlwqNJm03/?ref=app
13th Feb 2021, 6:56 AM
∆BH∆Y
∆BH∆Y - avatar
+ 1
it is now working . thanks.
13th Feb 2021, 7:37 AM
Kim Hammar-Milliner
Kim Hammar-Milliner - avatar
+ 1
Kim Hammar-Milliner does your device only won't turn off caps inside description field for non-code text? I guess not, because normal case is used for title, tags, code and even some letters of your "blocked" case ('SoRRY', 'It')... please do not take us for dumb ^^
13th Feb 2021, 11:49 AM
visph
visph - avatar
0
Dictionaries You are working at a car dealership and store the car data in a dictionary: car = { 'brand': 'BMW', 'year': 2018, 'color': 'red' } PY Your program needs to take the key as input and output the corresponding value. Sample Input: year Sample Output: 2018 The data is already defined in the code.
13th Feb 2021, 6:43 AM
Kim Hammar-Milliner
Kim Hammar-Milliner - avatar
0
i tried it and the test #3 still fails
13th Feb 2021, 7:00 AM
Kim Hammar-Milliner
Kim Hammar-Milliner - avatar
0
i removed mileage and rerun the test and test 3 is still failing
13th Feb 2021, 7:26 AM
Kim Hammar-Milliner
Kim Hammar-Milliner - avatar
0
car = { 'brand':'BMW', 'year': 2018, 'color': 'red', 'mileage': 15000 } print(car[input()])
15th Feb 2021, 3:21 AM
Angelo Cabbab
Angelo Cabbab - avatar
0
I wrote as below x = input() print(car[x]) It was successed but now I know I did not need to make x to solve it. Thank you all!
5th Mar 2022, 12:36 AM
Earl
Earl - avatar