【发布时间】:2023-02-23 22:18:29
【问题描述】:
rooms = ["Front Door", "Living Room", "Kitchen", "Study", "Storage", "Basement", "Master Bedroom", "Bathroom", "Attic", "Garden"]
desc = ["Was it too scary?", "The TV is on, what can you find?", "It smells so bad!", "The Master did all his work here...", "It is so dark and so cold in here... Why is it so frosty?", "The Master has his secrets...", "Don't worry its just a bathroom!", "Rubbish and Antiques", "Beautiful, is it not?"]
roomLIT = [True, True, True, True, False, False, False, False, True]
roomLocked = []
username = input("Welcome Player! What is your username?")
age = input("What is your age?")
rn = int(input("Enter Room Number:"))
print("You have entered the", rooms[rn])
print(desc[rn])
rn = 1
leave = "yes"
while leave == "yes":
while rn != 0:
rn = int(input("Enter Room Number:"))
print(desc[rn])
leave = input("Do you want to leave?")
问题出在 while 循环中
问题在最后
【问题讨论】:
-
只问专业的。我猜这是一个作业,你需要学习和学习,我给个提示。要获得所需的行为,您可以更改外部 while 循环的条件以检查用户是否键入了“no”。如果答案为“否”,则继续循环并要求用户输入不同的房间号。如果用户说“是”,循环结束,程序结束。
标签: python while-loop