사용자가 (x, y) 격자에서 '보물'을 찾아야하고 올바른 (x, y) 값에 도달 할 때까지 프로그램이 반복되도록이 프로그램을 설계하고 싶습니다. 루프 설계 방법을 찾는 데 도움이 필요합니다.특정 값의 조합에 도달 할 때까지 프로그램을 반복 시키려면 어떻게합니까?
question = (input("Where do you want to go?: "));
y = 0
x = 0
if question in ["up"]:
y = y + 1
print("You've moved up one unit!")
print("Your position is now ", x, y)
if question in ["down"]:
y = y - 1
print("You've moved down one unit!")
print("Your position is now ", x, y)
if question in ["right"]:
x = x + 1
print("You've moved right one unit!")
print("Your position is now ", x, y)
if question in ["left"]:
y = y + 1
print("You've moved left one unit!")
print("Your position is now ", x, y)
else:
print("You can't go there.")
https://docs.python.org/3/tutorial/introduction.html#first-steps-towards-programming – jonrsharpe