2 ms·
By introducing a couple of functions: say() and audio_input(), you could make it into a talking game: number = 4 say("I'm thinking of a number") while Tr
by d0mine 9y ago
By introducing a couple of functions: say() and audio_input(), you could make it into a talking game:
number = 4
say("I'm thinking of a number")
while True:
try:
word = audio_input("Make a guess: ").lower()
except RuntimeError:
say("Try again")
else:
say(word)
guess = word2num.get(word)
if guess is None:
say("Not a number")
elif guess < number:
say("Too low!")
elif guess > number:
say("Too high!")
else:
say("You got it!")
break
Complete code example https://gist.github.com/3b3f26602e31198d399c643c8053b8b6 https://gist.github.com/3b3f26602e31198d399c643c8053b8b6