I'm working on an AI portion of a guessing game. I want the AI to select a random letter from this list. I'm doing it as a set so I can easily remove letters from the list as they are guessed in the game and are therefore no longer available to be guessed again.
it says set
object isn't indexable. How can I work around this?
import random
aiTurn=True
while aiTurn == True:
allLetters = set(list('abcdefghijklmnopqrstuvwxyz'))
aiGuess=random.choice(allLetters)
print (aiGuess)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…