python - 在 python 上不断收到此错误 E902 EOF

标签 python python-3.x

def computepay(hours, rate):
    if hours > 40.0:
        p = rate * 40.0


p = p+(1.5*rate*(hours-40))
else:
    p = rate*hours
return p
hours = float(input("Enter worked hours: "))
rate = float(input("Enter Pay rate per hour: "))
print computepay(hours, rate))

我在 defcomputepay 的多行语句中收到 E902 - EOF。

最佳答案

首先欢迎来到 Stackoverflow。 这是我用适当的缩进和括号更正后的代码。 它应该有效:

def computepay(hours, rate):
    if hours > 40.0:
        p = rate * 40.0
        p = p+(1.5*rate*(hours-40))
    else:
        p = rate*hours
    return p
hours = float(input("Enter worked hours: "))
rate = float(input("Enter Pay rate per hour: "))
print(computepay(hours, rate))

关于python - 在 python 上不断收到此错误 E902 EOF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58376178/

相关文章:

python - 如何填充python中几条曲线之间的区域?

python - 如何在python中提取float的十进制值

python - 创建循环?

自定义类的 Pythonic 方式

python - docker Airflow 配置问题 (puckel/docker)

python-3.x - 在 Python 中编写递归函数

python - 如何从 Python3 中给定的值列表中获取字符串中每个字符的值?

python - 生成临时文件名而不在 Python 中创建实际文件

python - 使用 selenium webdriver 等待元素的属性更改值

python - 使用 igraph python 从图中提取某个组件