I was wondering if it was possible to create a code like the one quoted.
I mean if it is possible to create an array with booleans (False), choose only one (randomly) and change its value (to True) and then be able to use it?
The first random choice should only be done once, when the program is launched.
Gentleman = False
Daughter = False
Madam = False
character_list = [Gentleman, Daughter, Madam] # an array with the bools above
for character in characters_list:
character = random.choice(characters_list) # Randomly pick a character from the list
character = True # Set the character as True
if Madam == True:
...
Madam = False
Daughter = True
...
if Gentleman == True:
...
Gentleman = False
Madam = True
...
if Daughter == True:
...
Daughter = False
Gentleman = True
...
PS: I know my code is wrong but it's just to try to illustrate what I would like to do
Thank you for your help
Update
So after trying what is written in the comment, I find myself with a problem
Gentleman = False
Daughter = False
Madam = False
character_list = [Gentleman, Daughter, Madam] # an array with the bools above
print(characters_list)
characters_list[random.randint(0, len(characters_list)-1)] = True
print(characters_list)
print("Starting up ...")
if Madam == True:
print("Hello Madam")
...
Madam = False
Daughter = True
...
Output
[False, False, False]
[False, False, True]
Starting up ...
Since I don't go into the if Madam == True: I guess I don't quite understand how to use it, what should I do to get my code to understand that the Madam has turned True and goes into the if statement
(Btw I am new to Python)