當前位置:成語大全網 - 新華字典 - python loop

python loop

1.首先,這個程序裏沒有loop.

但我猜妳的意思就是在score=-1(或者<0?)時候停止程序。

可以在程序最初加上

import sys

然後在

userscore=input('Enter the user’s score: ')

下行加上 if user score == -1:

print :"Error message..."

sys.exit(1)

2.如果妳真的問的是在for loop 或者 while loop中怎麽用條件來結束,

那麽同上,設置if 條件句

if user score == -1:

break