(range(3),range(3)) ValueError: too many values to unpack (expected 2)

user1942505 :
for x,y in (range(3),range(3)):
    print(x+','+y)

I wont a simple output of any pare of numbers something like that:

1,1
2,2
3,3

I get:

Traceback (most recent call last):
  File "<pyshell#36>", line 1, in <module>
    for x,y in (range(3),range(3)):
ValueError: too many values to unpack (expected 2)
kederrac :

you can use the built-in method zip:

for x,y in zip(range(3),range(3)):
    print(x, y, sep=',')

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=19458&siteId=1