News for hackers. Stuff that matters.
Re:A Universe in One Line of Code with 10 PRINT by d0mine on Monday November 13, 2017 @07:47AM (#15686073)
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

There are no comments on this comment yet.