为什么 Codecademy 给我一个意外的 EOF 错误?

Why is Codecademy giving me an unexpected EOF error?

提问人:Noah 提问时间:7/24/2023 最后编辑:Noah 更新时间:7/24/2023 访问量:31

问:

我是编程新手,我正在尝试使用 Codecademy 学习编码。当我尝试进行可选的复习练习时,我在尝试将 input() 函数合并到变量中时遇到了意外的 EOF 错误。

我尝试了以下代码。EOF 错误出现在第 6 行:

    print("I have information for the following planets:\n")

    print("   1. Venus   2. Mars    3. Jupiter")
    print("   4. Saturn  5. Uranus  6. Neptune\n")

    weight = input("Please enter Earth weight: ")

    planet = input("Please enter planet number: ")

    # Write an if statement below:
    if planet == 1:
      weight = weight * 0.91
      print("Your weight on Venus will be " + str(weight) + " lb.")
    elif planet == 2:
      weight = weight * 0.38
      print("Your weight on Mars will be " + str(weight) + " lb.")
    elif planet == 3:
      weight = weight * 2.34
      print("Your weight on Jupiter will be " + str(weight) + " lb.")
    elif planet == 4:
      weight = weight * 1.06
      print("Your weight on Saturn will be " + str(weight) + " lb.")
    elif planet == 5:
      weight = weight * 0.92
      print("Your weight on Uranus will be " + str(weight) + " lb.")
    elif planet == 6:
      weight = weight * 1.19
      print("Your weight on Neptune will be " + str(weight) + " lb.")
    else:
      print("Unknown planet")

此代码给出错误: 回溯(最近一次调用最后一次): 文件“space.py”,第 6 行,在 weight = input(“请输入地球重量:”) EOFError:读取一行时的 EOF

我希望能够在终端中为可变权重提供输入。相反,我遇到了一个错误。有人可以解释一下我可以做些什么来修复我的代码吗?

蟒蛇 python-3.x eof

评论


答: 暂无答案