0

24.2 PythonBeginners (Ticket prices)

I dont understand whats wrong and neither how to do it in another way. I want to put the input values in an array. And then go through them with a for loop. I DEFINITELY WANT TO DO IT IN THIS WAY so no other solutions please because then i can do it. My Code: price=0 i=0 age=[] while i <5: age=age.append(int(input())) for a in age: if a < 3: price+=0 else: price+=100 print(price)

4th Jun 2022, 8:10 PM
Lil Bebi
Lil Bebi - avatar
4 Respostas
+ 2
You need to increase "i" in the body of the while-loop. If you don't , "i" will always be smaller 5 and run infinitely.
4th Jun 2022, 8:15 PM
Lisa
Lisa - avatar
+ 1
Or use a for loop for the inputs, which will look cleaner
4th Jun 2022, 11:56 PM
Emerson Prado
Emerson Prado - avatar
0
Okay thank you guys. But still.. it doesnt work. I wrote i+=1 in the while loop. Just that you know that there isnt the problem
5th Jun 2022, 5:50 PM
Lil Bebi
Lil Bebi - avatar
0
Lil Bebi So let's do it in the right way. Edit your question with the following in the question description: 1. Insert a link to your code in Code Playground (use '+' button 2. Remove the old code 3. Explain what the code should do 4. Explain what it's doing instead This helps who wants to help you.
6th Jun 2022, 3:16 PM
Emerson Prado
Emerson Prado - avatar