Ask Your Question
0

A Zip problem

asked 2020-06-19 11:13:34 +0200

Cyrille gravatar image

I have two list of the same length

x=[10188.4, 3533.88, 773.924, 0.000000, 0.000000, 3749.69, 0.000000, 0.000000, 0.000000, 3395.03]
y=[163.350,  514.050, 864.750, 1215.45, 1566.15, 1916.85, 2267.55, 2618.25, 2968.95, 3319.65]

when i try

zip(x,y)

the result is <zip object at 0x6fcd7907988>

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2020-06-19 11:21:28 +0200

eric_g gravatar image

updated 2020-06-19 11:23:49 +0200

This is correct (in Python 3). If you really want the output to be a list, run

list(zip(x, y))

but if you want to use it in a loop, it's better to keep the zip object.

edit flag offensive delete link more

Comments

Thanks eric_g. but I have not seen this trick in the docs.

Cyrille gravatar imageCyrille ( 2020-06-19 13:53:56 +0200 )edit
0

answered 2020-06-19 11:49:38 +0200

Cyrille gravatar image

In fact, I have found in https://stackoverflow.com/questions/3... that in Python3 zip there is a change of usage :

xy=[*zip(x,y)]

works -- see https://stackoverflow.com/questions/3...

There is perhaps the need to update the documentation (https://doc.sagemath.org/html/en/them...)

edit flag offensive delete link more

Comments

What update do you think is needed? The use of zip in the documentation is correct and follows Eric's point: if you want to use it in a loop, as is done in the documentation, keep it as a zip object. In any case, feel free to open a sage-trac account and propose edits to the documentation.

John Palmieri gravatar imageJohn Palmieri ( 2020-06-19 20:47:31 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-06-19 11:13:34 +0200

Seen: 918 times

Last updated: Jun 19 '20