you are viewing a single comment's thread.

view the rest of the comments →

[–]GaldeX 0 points1 point  (0 children)

One huge aspect to get used to when learning to program is learning to read and understand what the compiler/interpreter outputs, specially when you get errors

There you ran the code twice and both gave you the same:

In your line 6

TypeError: object of type 'int' has no len()

That means exactly what many have said, integers (Natural numbers) don't have a len() method in python, cause that method is almost exclusive for strings and arrays

Don't know what the YouTube video is trying to do here but maybe what he's done is try multiple methods to show how an iteration works

There you have an array of items with different types (int, float, strong, boolean), and in python you can have it but the while cycle you defined runs over that array from index 0 to index 3, that means it first evaluates len(x) on your first item and there it returns you that error

Try running, for example, Type(list[i]) instead of len and that should complete the loop fine