I am trying to use the code below to check if someone is allowed to ride a coaster. The first part is to create a 2D list and the second part is for the checking.
heights = [165, 154, 156, 143, 168, 170, 163, 153, 167]
ages = [18, 16, 11, 34, 25, 9, 32, 45, 23]
heights_and_ages = list(zip(heights, ages))
heights_and_ages = [list(info) for info in heights_and_ages]
can_ride_coaster = []
for info in heights_and_ages:
for height, age in info:
if height > 161 and age > 12:
can_ride_coaster.append(info)
I get the error on the line 19
for height, age in info:
error is:
line 19, in <module>
for height, age in info:
TypeError: cannot unpack non-iterable int object
I think it's because I use two variables bcs it's alright if I use one, but after searching online that doesn't seem to be a problem. How can I fix this?