Why is my loop stopping after one iteration? (python) | Sololearn: Learn to code for FREE!

-1

Why is my loop stopping after one iteration? (python)

items = int(input()) days = int(input()) #your code goes here x = 1 total = 0 while x <= days: total = days * items x = x + 1 print(total)

11/30/2021 3:25:51 AM

Evan Bain

6 Answers

New Answer

+2

IMHO it should be total+=days*items

+1

It depends on the value of days.

+1

What are you trying to do?

+1

It's not stopping, you're doing the same thing on every iteration.

+1

It is all depend on what u have enter in days (input). when u enter 1 to days ur program will run just one iteration

+1

1- it depends on the days input 2- you are just repeating the same thing because days and items are not changing 3- the print is outside the loop so it will only print the last iteration