0
Help understanding this while loop
raybans = int(input("Enter the amount you'd like to purchase mo more than 5: ")) price = 150 while raybans <= 5: print("This statement shows what you\'ve purchased and the quantity, "+ str(raybans)+ " \nand prices are shown below. ") print(raybans * price) raybans = raybans + 1 total_raybans = raybans * price if total_raybans <= 750: #close to figuring out print("Budget has been met. ") elif total_raybans > 750: print("Budget has gone over board. ") #anaylyze the above while loop, i am having a difficulty understanding why on the last iteration or loop which suppose the user decides to input 5. Why when it is ran total_raybans <= 750 runs false or Budget has gone over board.
1 Odpowiedź
+ 2
Jacob Barrientos
while loop works until the condition meet.
So here loop will work till raybans <= 5 is true.