B和C不起作用(Python3)

时间:2017-08-26 10:00:43

标签: python python-3.x

我很担心为什么选择" B"或" C"不起作用。您应该能够通过选择3个选项中的任何一个来导航故事。有效的唯一选择是" A"。这可能是我忽略的最小的事情。

Click to See the Code Window

程序执行(来自Fuctions.py,SplashScreens()):

...
print(SplashScreen.Splash_Screen19)
cls()
Story_1_to_4(Text.Story_1,2,3,4)

运行此... ...(位于Functions.py){Through = True} {Key = False}

def Story_1_to_4(Story_Num, Path1, Path2, Path3):
global Through
global Key
if Path1 == 3 and Path2 == 4 and Path3 == 10:
    Key = True
while Through == True:
    Choice = input(Story_Num)
    if Choice == "A":
        Choice = Path1
        Through = False
    elif Choice == "B":
        Choice = Path2
        Through == False
    elif Choice == "C":
        Choice = Path3
        Through == False
    else:
        cls()
        print(Text.Invalid_Syntax)
        time.sleep(2)
        cls()
ResetThrough()
Decision(Choice)

Story_1 :(来自Text.py)

Image of the Variable Story_1

然后决定是......(位于Functions.py)

def Decision(Choice):
cls()
if Choice == 1:
    Story_1_to_4(Text.Story_1,2,3,4)
elif Choice == 2:
    Story_1_to_4(Text.Story_2,3,4,10)
elif Choice == 3:
    Story_1_to_4(Text.Story_3,5,6,4)
elif Choice == 4:
    Story_1_to_4(Text.Story_4,7,8,9)
elif Choice == 5:
    Story_Ending(Text.Story_5)
elif Choice == 6:
    Story_Ending(Text.Story_6)
elif Choice == 7 and Key == True:
    Story_Ending(Text.Story_7_With_Key)
elif Choice == 7 and Key == False:
    Story_Ending(Text.Story_7_Without_Key)
elif Choice == 8:
    Story_Ending(Text.Story_8)
elif Choice == 9:
    Story_Ending(Text.Story_9)
elif Choice == 10:
    Story_Ending(Text.Story_10)

1 个答案:

答案 0 :(得分:2)

对于A,您设置Through = False。对于B和C,您编写了Through == False,它只评估表达式但不指定Through