Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 13861

How to fix ValueError: too many values to unpack (expected 3) in Python?

$
0
0

I have a dataset called records, a dataset sample looks like:

user_id movie_id genre1       1001     action2       1002     drama3       1003     comedy4       1004     drama...     ...      ...    

I would like to iterate over records in the following way:

for user, movie, genre in records:    print(user, movie, genre)

It first prints some rows and then shows this error:

44892 113769 comedy44892 113769 drama...  ------------------------------------------------ ValueError Traceback (most recent call last) in ----> 1 for user, movie, genre in records:      2     print(user, movie, genre)ValueError: too many values to unpack (expected 3)

What is wrong and how to fix it?


Viewing all articles
Browse latest Browse all 13861

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>