簡體   English   中英

這是我在 Python 中的剪刀石頭布游戲

[英]This is for my Rock, Paper Scissors game in Python

while True: print("Enter Choice \n 2 for Rock \n 2 for Paper \n 3 for Sciccors") break
   

我預計break語句會中斷 while 循環,但它沒有。 它向我展示了SyntaxError: 'break' outside loop

看起來您的 python 代碼沒有通過將每個代碼放在單獨的行中來格式化。

所以這:

while True: Print("Enter Choice \n 2 for Rock \n 2 for Paper \n 3 for Sciccors") break

應該是這樣的:

while True:
     print("Enter Choice \n 2 for Rock \n 2 for Paper \n 3 for Sciccors")
     break 

給出 output:

Enter Choice 
 2 for Rock 
 2 for Paper 
 3 for Sciccors

您必須使用斷行連接不同的語句; . 例如:

while True: 
    print("Enter Choice \n 1 for Rock \n 2 for Paper \n 3 for Scissors")
    break

要么

while True: print("Enter Choice \n 1 for Rock \n 2 for Paper \n 3 for Scissors"); break

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM