Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

Python 3.9.5 (tags/v3.9.5:0a7dcbd, May 3 2021, 17:27:52) [MSC v.

1928 64 bit
(AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> def shuffle_list (mylist):
... shuffle (mylist)
... return mylist
...
>>> mylist = [' ','o',' ']
>>> def player_guess():
... guess=''
... while guess not in ['0','1','2']:
... guess = input ("Pick a number 0,1,2")
... return int(guess)
...
>>> def check_guess (mylist,guess):
... if mylist[guess] == 'o':
... print ("correct")
... else:
... print ("wrong")
... print (mylist)
...
>>> mylist = [' ','o',' ']
>>> mixedup_list = shuffle_list(mylist)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in shuffle_list
NameError: name 'shuffle' is not defined
>>> from random import shuffle
>>> mixedup_list = shuffle_list(mylist)
>>> guess = player_guess()
Pick a number 0,1,20
>>> check_guess(mixedup_list,guess)
correct
>>>

You might also like