开发者

ValueError: need more than 1 value to unpack

开发者 https://www.devze.com 2023-01-07 09:18 出处:网络
Here\'s the line that throws this error (x,neighbor) = random.sample(out_edge_list,开发者_StackOverflow1)

Here's the line that throws this error

(x,neighbor) = random.sample(out_edge_list,开发者_StackOverflow1)


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)


Here the solution. I changed the line to

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

精彩评论

暂无评论...
验证码 换一张
取 消