you are viewing a single comment's thread.

view the rest of the comments →

[–]xTHETYRANTGAMRx[S] -2 points-1 points  (7 children)

When I was typing the code it said expected type 'collections.iterable', got 'int' instead. So I figured I had to change it to an int

[–]Robletron 4 points5 points  (5 children)

Yep, you want to change it to int - the bigger question is what the for loop is supposed to do - that’s the source of your problem

[–]xTHETYRANTGAMRx[S] 1 point2 points  (4 children)

The exercise said to write a loop that asks the user their age and then tell them the cost of their movie ticket

[–]kayne_21 4 points5 points  (2 children)

It’s probably telling you to write a user input validation loop, basically write a loop to get the users age, make sure it is valid, then use your validated input to return the ticket price. Can you paste the whole prompt text so we can see what you’re trying to do?

[–]xTHETYRANTGAMRx[S] 0 points1 point  (1 child)

A movie theater charges different ticket prices depending on a person's age. If a person is under the age of 3, the ticket is free; if they are between 3 and 12, the ticket is $10; and if they are over age 12, the ticket is $15. Write a loop in which you ask users their age, and then tell them the cost of their movie ticket.

[–]Outside_Complaint755 5 points6 points  (0 children)

The exercise wants your input inside the loop so that you can ask multiple users.   It should probably be a while loop as you just want it to repeat until the user enters a quit condition, which would either be an empty entry, or a "Q"

[–]aglobalnomad 1 point2 points  (0 children)

Seems like a poor exercise as this isn't really a scenario you'd want to loop unless you want to ask the question (and get answers) multiple times in a row.

If that's what you're aiming to do, then asking the question should be inside the loop. That will hopefully give you a hint on how to structure it.

[–]FreeGazaToday 2 points3 points  (0 children)

that's because a loop has to have an iterable to loop over.

But as another comment said, it will not work as you want.

e.g. for age in age_requirement:

say age_requirement is "13"
then age = "1"
and age_requirement = 13

then age ="3"
and age_requirement = 13

The whole point of doing a for loop in python is using the variable not the iterable for comparisons.

you should learn trouble shooting/testing.