Skip to content
Advertisement

Tag: iterable

Iterables / generators with specified length

Iterable objects are those that implement __iter__ function, which returns an iterator object, i.e. and object providing the functions __iter__ and __next__ and behaving correctly. Usually the size of the iterable object is not known beforehand, and iterable object is not expected to know how long the iteration will last; however, there are some cases in which knowing the length

‘int’ object is not iterable while using zip in python

Error : Traceback (most recent call last): File “”, line 8, in TypeError: ‘int’ object is not iterable It works when I convert list object to string but not working in int. Answer Because indexing will give back the object and not an iterable container here. unless you call it like this: zip([a[i]], [a[j]], [a[k]]).

What type of iterable is “x for x in y”?

I’ve been confused of list comprehension in Python, although its shorthand doing for loop is very convenient. I’m not sure if what’s in the join() function’s parameter below is list comprehension since usually you put [] around to show it’s a list comprehension. My question: What’s the type of iterable produced by str(x) for x in res[::-1] in join() below?

Advertisement