小编Rya*_*yan的帖子

我的错误在哪里?(54行代码)

这是我当前的代码,当我运行它时,我得到一些错误......我不确定它们是什么.

Traceback(最近一次调用最后一次):

文件"D:/.实际W4/Lab3Problem1.py",第54行,在main()中

主nestediffunction()中的文件"D:/.Actual W4/Lab3Problem1.py",第8行

文件"D:/.Actual W4/Lab3Problem1.py",第27行,在nestediffunction if(booksread == 0):

NameError:未定义名称'booksread'

def main():
    print("Welcome to Ryan's book club!")
    booksread = int(input('Please enter the amount of books you have read so far: '))
#   if (booksread < 0):
#       print("That's impossible! Please  re-enter the amount of books you have read: ")
#       booksread1 = int(input('Please enter the amount of books you have read so far: '))        
    #simpleiffunction()
    nestediffunction()
    #eliffunction()




def simpleiffunction():
    if (booksread == 0):
        print('You have 0 points!')
    if (booksread …
Run Code Online (Sandbox Code Playgroud)

python variables if-statement

1
推荐指数
1
解决办法
89
查看次数

为什么我会收到语法错误?

sales = 1000

#def commissionRate():  

if (sales < 10000):
    print("da")  
else:
    if (sales <= 10000 and >= 15000):
        print("ea")
Run Code Online (Sandbox Code Playgroud)

if (sales <= 10000 and >= 15000):行上的语法错误.特别是在等号上.

python if-statement

0
推荐指数
1
解决办法
64
查看次数

标签 统计

if-statement ×2

python ×2

variables ×1