mrN*_*cky 5 python python-3.x atom-editor
这很奇怪,因为我的代码在在线 python 解释器中运行良好,但是当我在带有 Atom 的 linux mint 中运行它时,当我输入一个单词时出现此错误消息:
File "<string>", line 1, in <module>
NameError: name 'lol' is not defined
Run Code Online (Sandbox Code Playgroud)
这是我的代码
# -*- 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 : ")
Run Code Online (Sandbox Code Playgroud)
小智 9
尝试使用raw_input代替input. 听起来在在线解释器中,您可能正在 Python 3 中运行代码,其中的input行为类似于 Python 2 raw_input,并在本地使用 Python 2。
在 python 2 中,input您的代码会为您的输入寻找定义,而不是将其作为字符串。
| 归档时间: |
|
| 查看次数: |
20690 次 |
| 最近记录: |