python - Codeforces 上的“输出格式错误,文件意外结束 - 预期令牌”错误
问题描述
Codeforces 的问题是:
- input w (watermelon weight) is between 1 and 100.
- if watermelon can be split into two parts, each weighing even number of kilos, print YES, otherwise print NO
我的代码(Python 3)是
w = input()
w = int(w)
if w >= 4 and w%2 == 0:
print('YES')
else:
print('NO')
当我输入时8
,我得到输出YES
,因为它应该是。
但是,当我提交我的文件时,它wrong answer to test 1
说
Input
8
Participant's output
Jury's answer
YES
Checker comment:
wrong output format Unexpected end of file - token expected
有人可以解释一下我错过了什么吗?我试图找到这个确切的错误并弄清楚但无济于事
解决方案
在我朋友的帮助下解决了这个问题,所以我只想回答我自己的问题,以防其他人遇到同样的问题。
我使用 Jupyter notebook 来解决这个问题,所以我的文件有一个 .ipynb 扩展名,这就是为什么现场的求解器无法识别实际代码的原因。解决方案是上传一个 .py 扩展名(例如,在记事本中复制/粘贴代码并给它一个 .py 扩展名),然后它被接受了。
推荐阅读
- c - fread 没有读取整个文件
- mysql - 选择 N 个最高值,包括 MySQL 中的重复项
- git - 如何在 git 中正确映射远程服务器的 Windows 路径?
- python - cv2.videocapture(1) 和 cv2.videocapture(0) 有什么区别?
- javascript - 创建新项目时 npm init 不起作用
- java - 在 bean spring mvc websphere liberty 上找不到 @EventListener 注释
- javascript - GLTF 应该加载但永远不会出现在 chrome 中
- python-3.x - 如何在python中为路径列表生成树结构字典
- logistic-regression - 多项逻辑回归和多重共线性
- database - 如何解决 IoTDB 中 tsfile 过多的问题