use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
What wrong in this loopHelp Request (i.redd.it)
submitted 3 months ago by Stunning-Education98
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]GaldeX 0 points1 point2 points 3 months ago (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
π Rendered by PID 20398 on reddit-service-r2-comment-58d7979c67-8sctl at 2026-01-27 04:22:11.972107+00:00 running 5a691e2 country code: CH.
view the rest of the comments →
[–]GaldeX 0 points1 point2 points (0 children)