所以基本上這是我的學校作業我們一直在Python上編寫一個小測驗使用空閒我試着給Rerty添加一個循環如果你做得不好,但是當你輸入0時爲了關閉它應用程序就像它應該做的那樣關閉,但是當我將1放到Rerty時,它會一遍又一遍地重新執行相同的命令,並且不會重新開始測驗。這是腳本。當我在Python中輸入循環命令時,它不遵循語句?
-2
A
回答
1
現在你只需要在那裏問他們,如果他們想再次嘗試部分腳本循環,它沒有辦法控制流動回升到年初,並要求所有的問題。
考慮改變與函數定義
def quiz():
# code that asks questions goes here
# show them their score ask if they want to go again
if yes:
quiz() # restart the function within itself (recursion)
else:
print ("okay bye")
quiz() # this is the first call that gets it all started
0
循環重新開始,其中while
語句是流量。眼下,因爲程序將測驗不重複測驗,然後被捕獲退出
answer.lower().startswith("0")
exit()
,只是重複循環,而這又只給出了選擇退出或重複循環之間。它重複循環,因爲你告訴它打印ok, carry on then
然後開始回到while
所以測驗獲取運行每次while
循環重新開始,您可以將測驗本身while
循環中。
while True:
QUIZ
quit = input('Retry or quit?')
if quit:
exit()
elif not quit
whatever you want to say here, the program won't exit so it starts back at the while
相關問題
- 1. Python不遵循'if語句'
- 2. python 2計時器不遵循命令
- 3. 循環輸入命令
- 4. for循環if語句不輸入
- 5. Python循環語句
- 6. 當輸入錯誤輸入時無限循環無限循環
- 7. 循環輸入和語句的列表
- 8. 直到語句/循環python?
- 9. python while循環break語句
- 10. 如何在Python中循環if語句?
- 11. 在Python中循環外部命令
- 12. 循環SQL語句插入
- 13. 我的if語句不能在Python中正確循環使用
- 14. 在while循環中插入SQL語句
- 15. 當IF語句爲真時,「Next」不能在循環中工作
- 16. 從命令行啓動時,在for循環中不顯示C++ cout語句
- 17. 粒子不遵循HTML命令
- 18. 在循環中加入命令
- 19. if語句循環在定時器中
- 20. 代碼不輸出,循環輸入語句
- 21. objective c - Break語句不在循環語句或switch語句中
- 22. Break語句不在循環語句或switch語句中?
- 23. if語句中的循環 - python
- 24. Python中else語句內外while循環
- 25. 雖然python中的語句循環
- 26. For循環不循環我的else語句(Java)?
- 27. 爲什麼它不遵循40號字體if語句
- 28. Google遵循按鈕/輸入
- 29. 在Python中命名循環
- 30. EVAL命令不循環
使您的問題更具可讀性。例如添加更多標點符號.. – Vova