Made a program that selects the minimum price from the presented. But with the output of 92 and 95, under the line print ('По запросу мы нашли лучшую цену!', gaz_92(), ' руб')
extra number is displayed, help please get rid of it. And if it's not difficult tell me how you can remove the numerous if in the code. Code:
price_gazprom = {'92': 41.10, '95': 44.20, '95+': 45.60, '100+': 51.40, 'ДТ': 47.75, 'Пропан': 21.20} price_rosneft = {'92': 43.00, '95': 45.00, 'ДТ': 48.10} price_novyi_potok={'92': 39.95, '95': 43.40, 'ДТ': 46.95} def gaz_92 (): p_end = 0 p_end = min(price_gazprom['92'], price_rosneft['92'], price_novyi_potok['92']) return p_end def gaz_95 (): p_end = 0 p_end = min(price_gazprom['95'], price_rosneft['95'], price_novyi_potok['95']) return p_end def DT (): p_end = 0 p_end = min(price_gazprom['ДТ'], price_rosneft['ДТ'], price_novyi_potok['ДТ']) return p_end print ('Приветствуем вас в программе подборки лучшей цены на топливо! Все представленные цены действительны на территории г.Тюмень и 300 км от него!') vvod = input('Введите желаемое топливо, а мы сравним все заправки и выберем лучшую цену! Ввод(92,95,95+,100+,ДТ,Пропан): ', ) if vvod == '92': print ('По запросу мы нашли лучшую цену!', gaz_92(), ' руб') if vvod =='95': print ('По запросу мы нашли лучшую цену!', gaz_95(), ' руб') if vvod == 'ДТ': print ('По запросу мы нашли лучшую цену!', DT(), ' руб') if vvod == '95+' or '100+' or 'Пропан': print (price_gazprom[vvod])
if vvod == '95+' or vvod == '100+' or vvod == 'Пропан':
- m0nte-cr1st0gaz_92
,gaz_95
,DT
, which do the same thing, you need to do one. If done correctly, noif
-a will be needed. - Enikeyschik