Answer the question
In order to leave comments, you need to log in
How to compare list and dictionary values in Python?
How to compare prices, otherwise I have some kind of problem with cycles, and the price is displayed for each product 8 times.
cost_now = [0.455, 0.455, 0.455, 0.078, 0.03, 0.03, 2.58, 2.545]
cost_before ={
'товар первый' : 0.99,
'товар второй' : 0.99,
'товар третий' : 0.99,
'товар четвертый' : 0.44,
'товар пятый' : 0.08,
'товар шестой' : 0.03,
'товар седьмой' : 2.3,
'товар восьмой' : 2.2
}
for name, cost in cost_before.items():
for i in cost_now:
if i > cost:
print (f'{name} сейчас стоит {i} +{i-cost:.3f}')
elif i == cost:
print (f'{name} сейчас стоит {i} без изменений')
else:
print (f'{name} сейчас стоит {i} -{cost-i:.3f}')
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question