Question: Write a loop were the numbers in a list are substrate by 1 until they reach 0 or 0

Write a loop were the numbers in a list are substrate by 1 until they reach 0 or 0<. The list will have variable values which can be any number and they should be in descending order. The loop must not subtract 1 to the lowest two numbers. In addition I need to know where the subtraction is being made as in what variable occurs. I need the code in Python please.

#This is the loop that I made, but it does not keep going until all variables are 0 or < 0. And when I try ti find the variable where the subtraction was made by using .index() it only shows if a number is or not in the list. And I want to know in what variable the subtraction was made.

x1 = int(input('num'))

x2 = int(input('num'))

x3 = int(input('num'))

x4 = int(input('num'))

x5 = int(input('num'))

list = [X1, X2, X3, X4, X5]

for e in range(2,len(list)): list[e] = list[e] - 1 print (list)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!