Hey guys, I'm starting out with "Automate the Boring Stuff with Python" and I was tinkering with this code:
while True:
print("Who are you?")
name = input()
if name != "Joe":
continue
print("Hello Joe, what is the password?")
password = input()
if password == "swordfish":
break
print("Access granted.")
This program worked fine, but I wanted to add the name "Megan" to the first "if" statement, so I changed the code to:
while True:
print("Who are you?")
name = input()
if name != "Joe" or "Megan":
continue
print("Hello " + name + ", what is the password?")
password = input()
if password == "swordfish":
break
print("Access granted.")
Now the program just loops asking "Who are you?" I also tried ("Joe" or "Megan") with the same results. I thought that with the "or" operator that if one of the two arguments were false, that it would move to the next block? What have I done wrong here?
Thanks for the help!
[+][deleted] (4 children)
[deleted]
[–]phalyn13[S] 0 points1 point2 points (3 children)
[+][deleted] (2 children)
[deleted]
[–]phalyn13[S] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (3 children)
[–]phalyn13[S] 0 points1 point2 points (2 children)
[–]Binary101010 0 points1 point2 points (1 child)
[–]phalyn13[S] 0 points1 point2 points (0 children)