+ 1
Intermediate python practice 2.2 what's wrong with first question
Keeps asking for the input although I used it
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
+ 1
So you were able to solve it? Great!
+ 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)
+ 1
Abdullah Mazeer Read the replies and examples carefully: we are supposed to print car[x], not car['brand']
0
Can you please link your code?
0
car = {
'brand':'BMW',
'year': 2018,
'color': 'red',
'mileage': 15000
}
x= input()
if x == 'brand' :
print (car['brand'])
0
You don't need an if-statement, just print out the value for whatever key the user inputs
0
I tried it keeps the input bar empty
0
I mean just print(car[x])?
0
No 🤣 ... Yes I see
Thanks lisssa
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