Python needs to compare the increase over the last month's payroll.
-
Help me with the task. The user's injecting ten numbers. Write a program that checks whether they're being streamlined at age. If there was one case where the ep fell relative to the last month, that would suggest that it did not grow and that the message should be printed. I've got that code. But I can't figure it out if it falls.
curr = 0 for month in range(11): prev = int(input('Введите зарплату: ')) if curr == 0: curr = prev continue if prev > curr: print('Зарплата увеличилась ') elif prev == curr: print('Зарплата не изменилась') else: print('Зарплата уменьшилась')
-
You have to do this:
prev = -1
for month in range(10):
curr = int(input(f'Введите зарплату за месяц №{month + 1}: '))if curr < prev:
print('Зарплата уменьшилась')
breakprev = curr
else:
print('Зарплата НЕ уменьшилась')
And you only have the first and the most recent elements in comparison.
P. S.
Such an approach may also be implemented (if payments are made through a gap):
months = (list(map(int, input().split())) + [0] * 10)[:10]
print("зарплата уменьшалась" if months != sorted(months) else "зарплата не уменьшалась")