+ 1

Intermediate python practice 2.2 what's wrong with first question

Keeps asking for the input although I used it

23rd Apr 2022, 5:38 PM
Ibrahim Alzein
Ibrahim Alzein - avatar
11 odpowiedzi
+ 3
car = { 'brand':'BMW', 'year': 2018, 'color': 'red', 'mileage': 15000 } x= input() print (car['brand']) I tried this one but still refuse the result .. it says you need to debug
23rd Apr 2022, 7:28 PM
Ibrahim Alzein
Ibrahim Alzein - avatar
+ 1
So you were able to solve it? Great!
23rd Apr 2022, 7:31 PM
Lisa
Lisa - avatar
+ 1
car = { 'brand':'BMW', 'year': 2018, 'color': 'red', 'mileage': 15000 } x= input() print (car[x]) This will fix it. (the input needs to be used as an index in the dictionary)
24th Apr 2022, 5:56 PM
Thomas Walker
+ 1
Abdullah Mazeer Read the replies and examples carefully: we are supposed to print car[x], not car['brand']
25th Apr 2022, 1:12 PM
Lisa
Lisa - avatar
0
Can you please link your code?
23rd Apr 2022, 6:59 PM
Lisa
Lisa - avatar
0
car = { 'brand':'BMW', 'year': 2018, 'color': 'red', 'mileage': 15000 } x= input() if x == 'brand' : print (car['brand'])
23rd Apr 2022, 7:21 PM
Ibrahim Alzein
Ibrahim Alzein - avatar
0
You don't need an if-statement, just print out the value for whatever key the user inputs
23rd Apr 2022, 7:23 PM
Lisa
Lisa - avatar
0
I tried it keeps the input bar empty
23rd Apr 2022, 7:23 PM
Ibrahim Alzein
Ibrahim Alzein - avatar
0
I mean just print(car[x])?
23rd Apr 2022, 7:26 PM
Lisa
Lisa - avatar
0
No 🤣 ... Yes I see Thanks lisssa
23rd Apr 2022, 7:29 PM
Ibrahim Alzein
Ibrahim Alzein - avatar
0
car = { 'brand':'BMW', 'year': 2018, 'color': 'red', 'mileage': 15000 } x= input() print (car['brand']) I tried this one but still refuse the result .. it says you need to debug
25th Apr 2022, 1:02 PM
Abdullah Mazeer
Abdullah Mazeer - avatar