Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

More Books

Students also viewed these Databases questions

Question

Write down the Limitation of Beer - Lamberts law?

Answered: 1 week ago

Question

Discuss the Hawthorne experiments in detail

Answered: 1 week ago

Question

Explain the characteristics of a good system of control

Answered: 1 week ago

Question

State the importance of control

Answered: 1 week ago