5
\$\begingroup\$

I'm pretty new to coding and I want to get an opinion on my coding. I am learning Python and I made a really simple heads and tails guessing game.

import random
import time
import easygui
import sys
while True:
    rand = random.choice(["Heads", "Tails"])
    firstguess = raw_input("Guess Heads or Tails: ")
    if firstguess == rand:
        print "Wow you win"
    else:
        print "That is wrong you suck so bad lol."
    time.sleep(2)
    answer = easygui.buttonbox("Play again?", choices=["Yes","No"])
    if answer == "Yes":
        easygui.msgbox("Ok")
    else:
        break

easygui.msgbox("Ok, see you later!")
sys.exit(0)
\$\endgroup\$
  • \$\begingroup\$ You are doing fine. My first program ever was a guessing game like this. Keep it up. \$\endgroup\$ – doug65536 May 6 '16 at 8:12
5
\$\begingroup\$

Why are you mixing raw_input() with easygui? That's a suboptimal user experience.

sys.exit(0) at the end is superfluous, but harmless.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.