Bruce
Bruce

Reputation: 35285

ValueError: need more than 1 value to unpack

Here's the line that throws this error

(x,neighbor) = random.sample(out_edge_list,1)

Upvotes: 1

Views: 1184

Answers (2)

Bruce
Bruce

Reputation: 35285

Here the solution. I changed the line to

(x,neighbor) = random.sample(out_edge_list,1)[0]

Upvotes: 0

Laurence Gonsalves
Laurence Gonsalves

Reputation: 143354

You're asking for 1 unique random element. So you're getting back something like [5]. If the 5 goes into x, what goes into neighbor?

Perhaps you meant to ask for 2 elements?

(x, neighbor) = random.sample(out_edge_list, 2)

Upvotes: 3

Related Questions