-2
#program to tic-tac-toe
from random import *
num=[i for i in range(1,10)]
flag=0
ulist=list();
xlist=list();
olist=list();
count=0
while(count < 9):
if(flag==0):
x=random.choice(num)
if(x not in ulist):
ulist.append(x)
xlist.append(x)
flag=1
if(flag==1):
o=random.choice(num)
if(o not in ulist):
ulist.append(o)
olist.append(o)
flag=0
count+=1
print (ulist)
print (xlist)
print (olist)
這是我的代碼,我呼籲隨機函數,但仍其說,我沒有使用隨機函數如何在python中使用隨機函數?
'X =的choise(NUM)'或'進口random'並保存代碼 – splash58