5

It's weird because my code works fine in online python interpreter but when I run it in linux mint with Atom, I have this error message when I enter a word:

File "<string>", line 1, in <module>
NameError: name 'lol' is not defined

Here is my code

# -*- coding: utf-8 -*-

word = str(input(" Enter a word : "))
reverse = word[::-1]
if reverse == word:
  print("it is a palindrome, félicitation : ")
else:
  print(" it is not a palindrome : ")
Aran-Fey
  • 39,665
  • 11
  • 104
  • 149
mrNicky
  • 155
  • 1
  • 1
  • 7

1 Answers1

11

Try using raw_input instead of input. It sounds like in the online interpreter you might be running the code in Python 3, in which input behaves like Python 2's raw_input, and using Python 2 locally.

In python 2, input results in your code looking for a definition for your input, rather than taking it as a string.

samwalton
  • 521
  • 4
  • 13
  • Thanks a lot ! It works fine, but the real problem is that I figure out that I am using python 2 in atom instead of python 3. I use help() to find which version I use. I am not a pro. – mrNicky Oct 01 '18 at 10:45