+ 1

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
14 Respostas
+ 5
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
+ 5
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
+ 2
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
+ 1
car = { 'brand':'BMW', 'year': 2018, 'color': 'red', 'mileage': 15000 } print(car[input()])
15th Feb 2021, 3:21 AM
Angelo Cabbab
Angelo Cabbab - 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 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
0
Passes all the tests user_input = input() car = { 'brand': 'BMW', 'year': 2018, 'color': 'red', 'mileage': 15000 } car_value = car.get(user_input, "Key not found in the dictionary!") print(car_value)
29th Aug 2023, 7:27 PM
Richa Caiado
Richa Caiado - avatar
0
user_input = input() car = { 'brand': 'BMW', 'year': 2018, 'color': 'red', 'mileage': 15000 } print(car[user_input]) This is without fun "get"
7th Oct 2023, 10:22 AM
defn
defn - avatar
0
Jdjdjdjd
27th Feb 2024, 5:36 PM
Prince Logesh Saravanan. J
Prince Logesh Saravanan. J - avatar
0
car = { 'brand':'BMW', 'year': 2018, 'color': 'red', 'mileage': 15000 } print(car[input()]) try this
8th Apr 2024, 6:29 AM
Rashmi Kulkarni
- 1
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