Python 无法通过镀锌文本编辑器运行代码

Python 无法通过镀锌文本编辑器运行代码,python,Python,作为一名初级程序员,我目前正在通过Python的镀锌车间处理一个实践问题,我遇到了一个问题。不幸的是,我不知道问题发生在哪里 问题是: 编写一个名为is_it_five_或_three的函数,将一个数字作为输入,如果该数字为5或3,则返回True。如果数字不是3或5,函数应返回False。 下面是我写的代码: x = int(input('Enter a number: ')) def is_it_five_or_three(x): if x == 5: return

作为一名初级程序员,我目前正在通过Python的镀锌车间处理一个实践问题,我遇到了一个问题。不幸的是,我不知道问题发生在哪里

问题是:

编写一个名为is_it_five_或_three的函数,将一个数字作为输入,如果该数字为5或3,则返回True。如果数字不是3或5,函数应返回False。

下面是我写的代码:

x = int(input('Enter a number: '))

def is_it_five_or_three(x):
    if x == 5:
        return True

    elif x == 3:
        return True

    else:
        return False


print(is_it_five_or_three (x))
当我通过Pycharm运行代码时,代码运行得非常完美(对于输入3或5为true,对于所有其他数字为false),但当我将其输入到镀锌提供的文本编辑器时,它会给我一个错误。有人知道可能是什么问题吗?提前谢谢

以下是供参考的错误:

E
======================================================================
ERROR: test_methods (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: test_methods
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/unittest/loader.py", line 428, in _find_test_path
    module = self._get_module_from_name(name)
  File "/usr/local/lib/python3.6/unittest/loader.py", line 369, in _get_module_from_name
    __import__(name)
  File "/usr/src/app/test_methods.py", line 6, in <module>
    import main
  File "/usr/src/app/main.py", line 3, in <module>
    x = int(input('Enter a number: '))
EOFError: EOF when reading a line```


----------------------------------------------------------------------
Ran 1 test in 0.000s

FAILED (errors=1)  

E
======================================================================
错误:测试方法(unittest.loader.\u失败测试)
----------------------------------------------------------------------
ImportError:无法导入测试模块:测试方法
回溯(最近一次呼叫最后一次):
文件“/usr/local/lib/python3.6/unittest/loader.py”,第428行,在查找测试路径中
module=self.\u从\u name(name)获取\u module\u
文件“/usr/local/lib/python3.6/unittest/loader.py”,第369行,在“从”name“获取”模块中
__导入(名称)
文件“/usr/src/app/test_methods.py”,第6行,在
进口干管
文件“/usr/src/app/main.py”,第3行,在
x=int(输入('输入一个数字:'))
EOF:读取一行时的EOF```
----------------------------------------------------------------------
在0.000秒内运行了1次测试
失败(错误=1)

错误是因为您使用
input
函数在不允许的环境中获取输入,因此当
input
尝试读取一行时,它会获取EOF(文件结尾)。镀锌车间是否明确表示要在此处使用
输入功能?