Sunday, May 30, 2021

TypeError: 'int' object is not iterable

I am starting to believe that the word "TypeError" is used in python with two meanings, first it indicates an invalid pair of data type and operation. Secondly it says "Oh a typo is encountered, looks like you forgot to type in something" and hence the TypeError !

I forgot to type range() in a for loop and it immediately reminded me about by giving an error 

TypeError: 'int' object is not iterable


😃😃

You will also get it if you forget to type range in a for loop : 

x = 5
for i in x:              #since x is obviously not iterable

We probably intended something like below : 

x = 5 
for i in range(x) : 

No comments:

Post a Comment

MCP 2025-11-25 vs. MCP 2026-07-28

A comparison of the major protocol changes introduced in the MCP 2026-07-28 specification. The following table co...