Trying to solve car data dictionary intermediate python challenge | Sololearn: Learn to code for FREE!

-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?

2/13/2021 6:39:38 AM

Kim Hammar-Milliner

9 Answers

New Answer

+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.

+4

Kim Hammar-Milliner It's 15000 not 5000 car = { 'brand':'BMW', 'year': 2018, 'color': 'red', 'mileage': 15000 } print(car[input()])

+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

+1

it is now working . thanks.

+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 ^^

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.

0

i tried it and the test #3 still fails

0

i removed mileage and rerun the test and test 3 is still failing

0

car = { 'brand':'BMW', 'year': 2018, 'color': 'red', 'mileage': 15000 } print(car[input()])