I have a door and there's a keypad code for it. If you get the code right you say Correct, if you get it wrong it just prints the wrong code (Just for debugging). However, I don't understand why nothing's happening when I code it. This is python btw:
realnumber = [12345]
inputnumber = []
def main():
integer = input("Input a list of numbers to open the door:")
if integer == realnumber:
print(realnumber)
print("Correct")
else:
inputnumber.append(integer)
main()
This is largely guess work but two issues stand out to me here:
integer = input("Input a list of numbers to open the door:")
You may not be a aware that the variable named integer here is going to a string regardless of your input. Might I suggest you try:
integer = int(input("Input a list of numbers to open the door:"))
or even better, something like this to catch nonsense input:
try:
integer = int(input("Input a list of numbers to open the door:"))
except ValueError:
print("Invalid Input")
Secondly,
if integer == realnumber:
Here you are trying to compare the variable "integer" (which is currently a string but with my suggested change will be an "int" variable) with realnumber, but realnumber is a list of variables that has only one input.
I suggest you choose one of these changes:
if integer == realnumber[0]:
or
realnumber = 12345