“UnboundLocalError: local variable 'input' referenced before assignment”

后端 未结 2 672
小鲜肉
小鲜肉 2020-12-19 14:29

When I run my code I get these errors:

linechoice = input(\"What password do you want to delete?:\\n\")

UnboundLocalError: l

2条回答
  •  别那么骄傲
    2020-12-19 14:43

    You are assigning a string to the variable input in

    y_n = input = ("Do you want to save these changes?\ny/n\n")
    

    input now has the value of 'Do you want to save these changes?\ny/n\n'

    However, you are also calling the built-in function input in

    linechoice = input("What password do you want to delete?:\n")
    

    Consider changing the name of your variable to avoid these conflicts.

    Looking at the context of the program, you are probably expecting

    y_n = input("Do you want to save these changes?\ny/n\n")
    

    instead of

    y_n = input = ("Do you want to save these changes?\ny/n\n")
    

提交回复
热议问题