Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
CuriosityKilledTheSphinx/alternative 2.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
129 lines (101 sloc)
4.01 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
sphinx story | |
is good | |
https://github.coventry.ac.uk/lycette2/CuriosityKilledTheSphinx | |
""" | |
history = [] # empty storage area for choices | |
def getAnswer1(question, text): # function to handle 1 response from the user | |
loop = True | |
choice = "" | |
while loop == True: | |
print(question) | |
choice = input("Enter choice:" | |
"\nA = " + text["A"] + | |
"\n->") | |
if choice == "a" or choice == "A": | |
print("You have selected A: " + text[choice.upper()]) | |
loop = False | |
else: | |
print("Please enter a valid option.") # runs if the answer is not valid | |
history.append(choice.upper()) # adds the choice the user picked | |
def getAnswer2(question, text): # function to handle 2 responses from the user | |
loop = True | |
choice = "" | |
while loop == True: | |
print(question) | |
choice = input("Enter choice:" | |
"\nA = " + text["A"] + | |
"\nB = " + text["B"] + | |
"\n->") | |
if choice == "a" or choice == "A": | |
print("You have selected A: " + text[choice.upper()]) | |
loop = False | |
elif choice == "b" or choice == "B": | |
print("You have selected B: " + text[choice.upper()]) | |
loop = False | |
else: | |
print("Please enter a valid option.") # runs if the answer is not valid | |
history.append(choice.upper()) # adds the choice the user picked | |
def getAnswer3(question, text): # function to handle 3 responses from the user | |
loop = True | |
choice = "" | |
while loop == True: | |
print(question) | |
choice = input("Enter choice:" | |
"\nA = " + text["A"] + | |
"\nB = " + text["B"] + | |
"\nC = " + text["C"] + | |
"\n->") | |
if choice == "a" or choice == "A": | |
print("You have selected A: " + text[choice.upper()]) | |
loop = False | |
elif choice == "b" or choice == "B": | |
print("You have selected B: " + text[choice.upper()]) | |
loop = False | |
elif choice == "c" or choice == "C": | |
print("You have selected C: " + text[choice.upper()]) | |
loop = False | |
else: | |
print("Please enter a valid option.") # runs if the answer is not valid | |
history.append(choice.upper()) # adds the choice the user picked | |
def getAnswer4(question, text): # function to handle 4 responses from the user | |
loop = True | |
choice = "" | |
while loop == True: | |
print(question) | |
choice = input("Enter choice:" | |
"\nA = " + text["A"] + | |
"\nB = " + text["B"] + | |
"\nC = " + text["C"] + | |
"\nC = " + text["D"] + | |
"\n->") | |
if choice == "a" or choice == "A": | |
print("You have selected A: " + text[choice.upper()]) | |
loop = False | |
elif choice == "b" or choice == "B": | |
print("You have selected B: " + text[choice.upper()]) | |
loop = False | |
elif choice == "c" or choice == "C": | |
print("You have selected C: " + text[choice.upper()]) | |
loop = False | |
elif choice == "d" or choice == "D": | |
print("You have selected D: " + text[choice.upper()]) | |
loop = False | |
else: | |
print("Please enter a valid option.") # runs if the answer is not valid | |
history.append(choice.upper()) # adds the choice the user picked | |
end = False | |
history = ["A","B","D"] | |
test = 0 | |
while end == False: | |
if history[0] == "A" and len(history) == 1: | |
print("This is passage A, and should never run.") | |
elif history[0] == "B" and len(history) == 2: | |
print("This is passage B, length 2, and will run once then stop.") | |
end = True | |
elif history[0] == "A" and len(history) == 3: | |
print("This should loop 5 times") | |
test = test + 1 | |
if test == 5: | |
history = ["B","A"] | |
print("history changed to:", history) |