I'm getting this error when using `zip()`. What could be the problem?

Question

Grade: Education Subject: Support
I'm getting this error when using `zip()`. What could be the problem?
Asked by:
69 Viewed 69 Answers

Answer (69)

Best Answer
(461)
The `zip()` function creates an iterator of tuples. If the input iterables have different lengths, `zip()` stops when the shortest iterable is exhausted. If you then try to unpack the zipped results expecting a certain number of values, but one iterable was shorter, you'll get this error. Use `zip_longest()` from the `itertools` module if you need to iterate through all elements of the longest iterable, filling in missing values with a specified fillvalue.