dimanche 17 décembre 2017

how to use random function in python?

#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)

this is my code i have called for the random function but still its saying i did not use the random function




Aucun commentaire:

Enregistrer un commentaire