2017-11-25 28 views
-4

beginner alert。這是我的tictactoe代碼,當我試圖檢查播放器是否輸入可播放值(1-9)時,我找不到問題。感謝幫助。使用while來檢查輸入是否在範圍python3

# the player now inserts input (coordinates of the field where he want his symbol written) 
    print('Player', p, ', go! Enter the position that you want to play.') 
    i = input() 
    i = int(i) - 1 

    while i in range(10,99): 
     print('entered number does not match any position in the game, try again') 
     break 
    else: 
     pass 
+0

而與替換。 – Frogboxe

+0

你應該看看https://stackoverflow.com/help/how-to-ask –

回答

0
if i not in range(1,10): 
    print("Invalid entry") 

您應該使用if語句

相關問題