0

I made this code the other day. It works fine except for the menu selection. Whenever I test it no matter what option I do for the menu it does reset password!

So, if I inserted 'Ill do a newgame!' it would respond with 'INSERT PASSWORD: ', beginning the reset password sequence.

I have all my code below:

import pickle
import time
# Beginning of program.
print ("Welcome to The Maze!")
time.sleep(2)
print ("Please enter your password to continue, or create a new one.")
has_pass = "false"
pass_correct = "false"
pass_input = "null"
password = "null"
with open('save_pass.dat', 'r') as sp:
    password, has_pass = pickle.load(sp)
if has_pass=="true":
    while pass_correct=="false":
        pass_input = raw_input("INSERT PASSWORD:  ")
        if pass_input==password:
            pass_correct = "true"
            print ("Password Correct")
elif has_pass=="false":
    password = raw_input("CREATE A NEW PASSWORD:  ")
    has_pass = "true"
with open('save_pass.dat', 'w') as sp:
    pickle.dump([password, has_pass], sp, protocol=2)
# Defining loadGame()
def loadGame():
    pass
# Defining newGame()
def newGame():
print("Are you sure? You will overwrite any existing data.")
reset = raw_input()
if "no" or "No" in reset:
    menu()
if "yes" or "Yes" in reset:
    level = 0
    points = 0
    with open('level_save.dat', 'w') as ls:
        pickle.dump([level, points], ls, protocol=2)
    loadGame()
# Defining menu()
def menu():
    print 10 * "~" , "Menu" , 10 * "~"
    print("1. New game\n2. Load previous game\n3. Reset password\n4. Exit")
    print("~" * 26)
    time.sleep(6)
    menu_select = raw_input("Please choose an option:  ")

It works well up to here...

    if "3" or "reset" or "Reset" in menu_select:
        with open('save_pass.dat', 'r') as sp:
            password, has_pass = pickle.load(sp)
        pass_correct = "false"
        if has_pass=="true":
            while pass_correct=="false":
                pass_input = raw_input("INSERT PASSWORD:  ")
                if pass_input==password:
                    pass_correct = "true"
                    print ("Password Correct")
        password = raw_input("CREATE A NEW PASSWORD:  ")
        has_pass = "true"
        with open('save_pass.dat', 'w') as f:
            pickle.dump([password, has_pass], f, protocol=2)
        time.sleep(2)
        print("Password succesfully saved!")
        time.sleep(5)
        menu()
    if "4" or "exit" or "Exit" or "quit" or "Quit" in menu_select:
            exit()
            quit()
    if "1" or "Newgame" or "newgame" or "new" or "New" in menu_select:
        newGame()
menu()

Could anyone help? I tried a lot of solutions but nothing worked.

0 Answers0