+ 1

Как упростить код?

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

14th Apr 2022, 8:17 AM
Владимир Ершов
Владимир Ершов - avatar
2 Answers
+ 2
x=input() print(car[x])
14th Apr 2022, 8:30 AM
NEZ
NEZ - avatar
+ 1
NEZ …😅😅 Thx))
14th Apr 2022, 9:14 AM
Владимир Ершов
Владимир Ершов - avatar