TypeError with map with no len()
Grant Edwards
grant.b.edwards at gmail.com
Mon Sep 25 13:11:45 EDT 2017
On 2017-09-25, john polo <jpolo at mail.usf.edu> wrote:
> Python List,
>
> I am trying to make practice data for plotting purposes. I am using
> Python 3.6. The instructions I have are
>
> import matplotlib.pyplot as plt
> import math
> import numpy as np
> t = np.arange(0, 2.5, 0.1)
> y1 = map(math.sin, math.pi*t)
> plt.plot(t,y1)
>
> However, at this point, I get a TypeError that says
>
> object of type 'map' has no len()
you probably need to convert y1 from a 'map' object (a type of an
iterator) to an array.
y1 = map(math.sin, math.pi*t)
y1 = np.fromiter(y1, float)
--
Grant Edwards grant.b.edwards Yow! Will this never-ending
at series of PLEASURABLE
gmail.com EVENTS never cease?
More information about the Python-list
mailing list