How can i express my code using functions? : How can i express my code by using functions, i have tried different solutions but still cant figure out how, any tip would help. It is a simple maze game that i have in my school, so it is a learning project and i dont need necessary the solution rather than any tip how to.
    
    x = 1
    y = 1
    valid_selection = True

    while True:
        if x == 1 and y == 1:
            if valid_selection == True:
                print("You can travel: (N)orth.")
            valid_selection = True
            choice = input("Direction: ")
            if choice.lower() == "n":
                y += 1
            else:
                print("Not a valid direction!")
                valid_selection = False
        elif x == 1 and y == 2:
            if valid_selection == True:
                print("You can travel: (N)orth or (E)ast or (S)outh.")
            valid_selection = True
            choice = input("Direction: ")
            if choice.lower() == "n":
                y += 1
            elif choice.lower() == "e":
                x += 1
            elif choice.lower() == "s":
                y -= 1
            else:
                print("Not a valid direction!")
                valid_selection = False
        elif x == 3 and y == 1:
            print("Victory!")
            break
