[Tutor] New programmer, need some help getting started on my first project
Chris Delgado
prowlerslim at yahoo.com
Fri May 19 02:44:43 CEST 2006
johnf,
Yup, I actually thought that might be my mistake but I forgot to actually try it. So I did and revised the code (which I'll post below) and now get a syntax error after my heads += line..yikes .
# A program that simulates flipping a coin 100 times and the reports the number of heads and tails that were flipped#
import random
heads = 0
tails = 0
flips = 0
if flips <= 100:
coin = random.randrange(2)
if coin == 0:
heads +=
else:
tails +=
flips += 1
print "The coin was flipped 100 times and it was heads" + heads + "times and tails" + tails + "times!"
raw_input("\n\nPress the Enter key to exit")
johnf <jfabiani at yolo.com> wrote: On Thursday 18 May 2006 16:19, Chris Delgado wrote:
> import random
>
> heads = 0
> tails = 0
> flips = 0
>
> if flips <= 100:
>
> coin = random.randrange(2)
>
> if coin = 0:
> heads +=
> elif coin = 1:
> tails +=
>
> flips +=1
>
> print "The coin was flipped 100 times and it was heads" + heads + "times
> and tails" + tails + "times!"
>
> raw_input("\n\nPress the Enter key to exit")
I think you want '==' and not '='. Look up assignment and equal!
John
_______________________________________________
Tutor maillist - Tutor at python.org
http://mail.python.org/mailman/listinfo/tutor
---------------------------------
Be a chatter box. Enjoy free PC-to-PC calls with Yahoo! Messenger with Voice.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060518/053b5167/attachment.html
More information about the Tutor
mailing list