I'm trying to use int in a for loop but the error message expected type 'collections.iterable' got 'int' instead appears

Viewed 36

I am trying to do is use a for loop to move a turtle but the error message expected type collections.iterable got int instead I have no idea why this is happening

fred = turtle
fred.shape("turtle")
for x in 20:
    fred.width(5)
    fred.forward(10)
1 Answers

the error refers to the line

for x in 20:

20 is of type int and cannot be iterated over you should use range()

for x in range(20):
Related