[Tutor] Python Code Not Working

Alan Gauld alan.gauld at yahoo.co.uk
Tue Oct 11 16:35:31 EDT 2016


On 09/10/16 21:39, jeremygainey14 at gmail.com wrote:
> Everytime I run this it says test is not defined . I don’t understand. 

It means test is not defined - that is, Python doesn't know
about it. You call a function test() but there is no such
function built into Python, so it complains.

Presumably the test function is defined in a module somewhere,
in which case you need to import that function to make it
visible to python.


Can someone please help correct?

> def is_palindrome(myStr):
>     if myStr in reverse(myStr):
>         return True
>     else:
>         return False
> 
> test(is_palindrome("abba"))
> test(not is_palindrome("abab"))
> test(is_palindrome("tenet"))

-- 
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