Float () should be a string or a number, not a "zip"

There are no problems when starting in python 2.7, but I get an error when starting in python 3.

Is there something I need to change in this code.

import matplotlib as mpl
poly = mpl.path.Path(zip(listx,listy))

The error I get is

TypeError: float() argument must be a string or a number, not 'zip'
+4
source share
1 answer

This is because python2 zip()returns a list of tuples, which it mpl.path.Path()happily accepts. In python3 zip(), iterator returns which you should consume. You should be able to do something like:

>>> poly = mpl.path.Path(list(zip(listx, listy)))
+8
source

Source: https://habr.com/ru/post/1659044/


All Articles