0
Ticket price sum
To calculate the sum of tickets that each cost 100 dollars we needed a code that only sums price for 5 passengers. And then only if they are 3 years or older. Why does the age=int(input)) have to go after the while loop and cannot be defined before it (e.g. in line 3)? Below the correct code. total = 0 x = 0 while x<5: x+=1 age=int(input()) if age <3: continue else: total += 100 print(total)
2 Respuestas
+ 2
Everything inside the loop is done multiple times. If you put the input() before the loop, it will be run only once, but you need to ask 5 numbers, that's why it's inside.
+ 1
Thank you!!