我在一般的“while”命令和循环中苦苦挣扎。我错过了一个停止点,但我不知道如何创建一个。我正在尝试创建一个程序来模拟原始股票期权选择,但它只是循环通过前两个循环而没有停止点。任何帮助,将不胜感激。
selection = " "
while selection not in ("r","R","t","T"):
print("This program can operate in random mode (fluctuations will randomly occur) or it can operate in test mode (fluctuations are fixed).")
print("(r)andom mode")
print("(t)est mode")
selection = input("Mode of operation:")
if selection not in ("r","R","t","T"):
print("\nPlease select 'r' or 't' for mode selection\n")
elif (selection == "r"):
print("Random mode enabled")
n = random.randrange(1,101)
selection = " "
while selection not in ("1","2","3"):
print("\tInvestment options:")
print("(1)Fly-By-Night Investments (FBN): high risk, high potential returns")
print("(2)Blue Chips INC. (BCI): moderate risk, good potential yearly returns")
print("(3)Slow-And-Steady-Corp. (SNS), mature industry stock: no risk but low returns")
selection = input("Please enter your investment option 1, 2, or 3:")
if selection not in ("1","2","3"):
print("\nPlease enter an investment option from the menu using 1, 2, or 3 as valid selections:\n")
随机和测试模式在程序的后面出现,但我想展示我在任何地方都没有停止点的循环。它只是在两者之间循环。