我想回到函數的頂部(不重新啓動它,但轉到頂部),但無法弄清楚如何做到這一點。而不是給你長的代碼,我只是要彌補我想要的一個例子:試圖循環到一個函數的開始(排序)python
used = [0,0,0]
def fun():
score = input("please enter a place to put it: ")
if score == "this one":
score [0] = total
if score == "here"
if used[1] == 0:
score[1] = total
used[1] = 1
elif used[1] == 1:
print("Already used")
#### Go back to score so it can let you choice somewhere else.
list = [this one, here]
我需要能夠回去所以基本上很難忘記你試圖使用「這裏」無需再次擦拭記憶。雖然我知道它們很糟糕,但我基本上需要一個去,但它們不存在於python中。有任何想法嗎?
*編輯:對不起,我忘記提及,當它已經被使用時,我需要能夠選擇其他地方去(我只是不想讓代碼停滯)。我把分數==「這一個」加了進去 - 所以如果我試圖把它放在「這裏」,「這裏」已經被採用了,它會給我重做分數=輸入(「」)的選擇,然後我可以拿該價值並將其插入「這一個」而不是「這裏」。你的循環語句會回到頂部,但不會讓我把我剛剛找到的值放到其他地方。我希望這是決策意識:對
使用'while'循環。 – 2013-04-27 20:04:31
@AshwiniChaudhary +1你應該發佈一個正確的答案。 – tripleee 2013-04-27 20:06:45