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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started