Where is 'palindrome' defined?
Denis McMahon
denismfmcmahon at gmail.com
Mon Jun 1 11:17:49 EDT 2015
On Sun, 31 May 2015 21:46:31 -0700, fl wrote:
>>>> def palindrome(num):
Note carefully the spelling(1): palindrome
>>>> parlindrome(a)
Note carefully the spelling(2): parlindrome
> NameError: name 'parlindrome' is not defined
Compare carefully spelling(1) and spelling(2).
palindrome is defined, pa_r_lindrome is not defined. The computer is not
psychic yet, so it doesn't know that when you wrote pa_r_lindrome you
meant palindrome, you have to spell it the same way every time for the
computer to recognise that you mean the same name.
Now you also know that the error message:
"NameError: name '<something>' is not defined"
means that you might have spelled <something> differently on the line in
the error message to the word you meant, so next time you see this error
message you know to carefully check the spellings of function names and
variables.
--
Denis McMahon, denismfmcmahon at gmail.com
More information about the Python-list
mailing list