TypeError: 'list' object cannot be interpreted as an integer
TypeError, cannot convert list object to an integer.
Error codes, such as the following example:
- args = [3,6]
- print(list(range(args)))
The range function should require an integer, or a pair of ranges, or three integer types to construct an iterable. It is not possible to directly pass the list of args to it. It needs to go through the decompression mechanism. The corrected code is:
- args = [3,6]
- print(list(range(*args))) # call with arguments unpacked from a list
Use *args to unpack the list and pass it to range to construct an itetable.