[Tutor] Strange error

Alan Gauld alan.gauld at btinternet.com
Thu Nov 19 13:29:02 EST 2015


On 19/11/15 10:06, jarod_v6--- via Tutor wrote:

> I have this error
>
>
> In [381]: len(Span)
> ---------------------------------------------------------------------------
> TypeError                                 Traceback (most recent call last)
> <ipython-input-381-6f83caae0041> in <module>()
> ----> 1 len(Span)
>
> TypeError: 'str' object is not callable


To call something in Python you use parens
- eg. to call f you use f()

So the error is talking about whatever has
parens after it. In this case that's len()
And it's saying len is a string.
That means somewhere in your code you have
created a variable called len and assigned
a string to it. You thus hide the built
in function len()

You need to delete the len variable.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list