newbie: Syntax error
Bill Mill
bill.mill at gmail.com
Fri Feb 4 14:00:30 EST 2005
Chad,
try "elif tries == 2" or just "else:". You are not allowed to put an
expression after an else statement.
I recommend you read the python tutorial at
http://docs.python.org/tut/tut.html .
Peace
Bill Mill
bill.mill at gmail.com
On Fri, 4 Feb 2005 12:49:51 -0600, Chad Everett <everettcc at hotmail.com> wrote:
> Hi Everyone,
>
> I am new to Python and programming in general. I bought the book "Python
> Programming for the Absolute Beginner" by michael Dawson.
>
> I have been working through it but am having trouble.
> I am trying to make a coin flip program and keep geting a Synax Error
> "invalid syntax".
>
> If anyone has a moment could you please look at it and tell me what I am
> doing wrong.
>
> thanks for your time and patience.
>
> Chad
>
> # Coin Flip Program
> # This program flips a coin 100 times and tells the number of heads and
> tails.
> # Chad Everett 2/3/2005
>
> print "\t\t********Coin Flip Game*********\n"
> import random
>
> # heads = 1
> # tails = 2
>
> tries = random.randrange(2) + 1
> count = 1
>
> while count != 100:
> if tries == 1:
> heads = 1
> count += 1
>
> else tries == 2: # I AM GETTING THE SYNTAX ERROR HERE
> tails = 1
> count += 1
>
> print "heads: " + heads
> print "tails: " + tails
>
> raw_input("Press enter to quit")
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list