Guessing Game (Heads or Tails) You guess heads or tails by clicking one of the buttons on easyGUI.  If it's right, you will get a "good job" message.  If it's wrong, you will get a "wrong" message! After that, there is an option to play again.

Please give me some feedback on how I can make my code better, if there is room for improvement.

import random
import time
import easygui
import sys
while True:
    rand = random.choice(["Heads", "Tails"])
    firstguess = easygui.buttonbox("Pick one", choices= ["Heads", "Tails"])
    if firstguess == rand:
        easygui.msgbox("Wow you win!")
    else:
    easygui.msgbox("Sorry you guessed wrong!")
    time.sleep(2)
    answer = easygui.buttonbox("Play again?", choices=["Yes","No"])
    if answer == "Yes":
        pass
    else:
        break

easygui.msgbox("Ok, see you later!")
sys.exit(0)
Your script isn't bad. But there is always room for improvement:


It's bad to mix tabs and spaces.  The fact that your code broke when you pasted it here shows why.  Good editors have a setting that will help you with this.  (It is recommended that you use spaces only.)
You don't need sys.exit(0) at the end of your script, since Python will exit automatically when it reaches the end.
Choose your variable names carefully. rand is not very descriptive and firstguess is plain incorrect (every guess, not just the first, gets assigned to this variable).
Don't repeat yourself.  Don't write ["Heads", "Tails"] twice, because if you have to change it for whatever reason, you have to remember to change it in two places.  Store it in a variable.
You can simplify this:

if answer == "Yes":
    pass
else:
    break


To this:

if answer != "Yes":
    break

I don't know easygui, but it seems you should use a
ynbox
when you're asking "yes or no?".  So you can change this:

answer = easygui.buttonbox("Play again?", choices=["Yes","No"])
if answer != "Yes":
    break


To this:

play_again = easygui.ynbox("Play again?")
if not play_again:
    break


Or simply:

if not easygui.ynbox("Play again?"):
    break



With all the changes made and after applying the rules from the the Python style guide PEP8, your code looks like this:

import random    # alphabetic order
import time

import easygui    # third-party modules after standard-library modules

CHOICES = ["Heads", "Tails"]    # ALL_CAPS for variables whose value never changes

while True:
    result = random.choice(CHOICES)
    guess = easygui.buttonbox("Pick one", choices=CHOICES)
    if guess == result:
        easygui.msgbox("Wow you win!")
    else:
        easygui.msgbox("Sorry you guessed wrong!")
    time.sleep(2)
    if not easygui.ynbox("Play again?"):
        break

easygui.msgbox("Ok, see you later!")