Reputation: 29
Basically, I want to make a game something like among us, but different, just for fun Anyways whenever I try to make it work, it will say my desired message no matter what. Here's the code:
import turtle
t=turtle.Turtle()
import random
imposteris = ['red', 'blue', 'green', 'cyan', 'lime', 'black', 'white', 'purple', 'orange', 'brown']
random.choice("imposteris")
n = 1
print("Welcome to among them, you are a detective, figure out who the imposter is")
meeting = int(input("Press 1 if you want to call a meeting"))
if meeting:
input("A meeting has been called! Who do you think the imposter is?, Do either red, blue, green, cyan, lime, black, white, purple, orange, brown")
for i in range(n):
if random.choice(imposteris):
print("Congratulations, You caught the imposter.")
else:
print("He was a crewmate :/")
Upvotes: 0
Views: 103
Reputation: 46
I took out your import of the Turtle module in order to test the code but you can put it back later.
import random
imposters = ['red', 'blue', 'green', 'cyan', 'lime', 'black', 'white', 'purple', 'orange', 'brown']
print("Welcome to among them, you are a detective, figure out who the imposter is\n")
print("Press 1 if you want to call a meeting")
meeting = int(input("> "))
if meeting:
imposter = imposters[random.randint(0, len(imposters) - 1)]
print(imposter)
print("A meeting has been called! Who do you think the imposter is?, Do either red, blue, green, cyan, lime, black, white, purple, orange, brown")
imposterGuess = str(input("> "))
if imposter == imposterGuess:
print("Congratulations, You caught the imposter.")
else:
print("%s was a crewmate :/" % imposterGuess)```
Upvotes: 2
Reputation: 52
You do have to link a variable to your random choice, so in this case: your_variable = random.choice(imposteris)
then you can do whatever you want with the variable for example: print(your_variable)
Upvotes: 3