How to select from a list instead of between two numbers with randint?


#1

I am writing a code for a game in Python where there is a maze, I want to form a random integer that can only contain 1's and 2's which I can translate to strings (r, and l, for right and left) then create a guessing game type of thing where the user tries to choose right or left and make their way through the maze.


#2

you could use randint, just import it to use it:

from random import randint

then you can use it, if you want a list you could do:

options = [randint(1,2) for x in range(10)]

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.