I am trying to make a "terminal hack" game but I am stuck at somewhere.
This is what my code currently looks:
import random
candidateWords = ['AETHER', 'BADGED', 'BALDER', 'BANDED', 'BANTER', 'BARBER'] #etc, etc
def wordlist(word):
for index, item in enumerate(random.sample(list(candidateWords), 8)):
print(index, ") ", item, sep='')
one = random.choice(candidateWords)
print(one)
print("Welcome to the Guess-The-Word Game.\nThe Password is one of these words:")
I'm trying to make a list of 8 words and enumerate it to give a number for each word. Then, from the 8 words, I need to randomly choose a word to be the answer but I don't know how.
I want to use random.sample()
and random.choice()
.
Aucun commentaire:
Enregistrer un commentaire