fork download
  1. # Import the modules
  2. import sys
  3. import random
  4.  
  5. ans = True
  6.  
  7. while ans:
  8. question = raw_input("Ask the magic 8 ball a question: (press enter to quit) ")
  9.  
  10. answers = random.randint(1,8)
  11.  
  12. if question == "":
  13. sys.exit()
  14.  
  15. elif answers == 1:
  16. print "It is certain"
  17.  
  18. elif answers == 2:
  19. print "Outlook good"
  20.  
  21. elif answers == 3:
  22. print "You may rely on it"
  23.  
  24. elif answers == 4:
  25. print "Ask again later"
  26.  
  27. elif answers == 5:
  28. print "Concentrate and ask again"
  29.  
  30. elif answers == 6:
  31. print "Reply hazy, try again"
  32.  
  33. elif answers == 7:
  34. print "My reply is no"
  35.  
  36. elif answers == 8:
  37. print "My sources say no"
Runtime error #stdin #stdout #stderr 0.01s 119552KB
stdin
Standard input is empty
stdout
Ask the magic 8 ball a question: (press enter to quit) 
stderr
Traceback (most recent call last):
  File "prog.py", line 8, in <module>
    question = raw_input("Ask the magic 8 ball a question: (press enter to quit) ")
EOFError