[docs] Else ,elif
abjimnen at aol.com
abjimnen at aol.com
Wed Sep 25 20:45:27 CEST 2013
I am new to programming but have been seriously been bitten by the buy and I am working with the book Python for Dummies by Stef Maruch and Aahz Maruch. I am working on a coin toss program which is suppose to be something like MY issue is that when I try to use the else or elif function it comes back as SyntaxError: invalid syntax and search as I might I can' t seem to find help to address this one issue. And I was hoping you guys can lead me someplace to solve this. I am using Python 3.3.2 on a Mac.
Yours Truly
Roman
import random
userinput = ' '
print "Now tossing a coin "
while userinput.lower() != "q":
flip = random.choice(['heads', 'tails'])
if flip == 'heads':
headcount+= 1
print "heads! the number of heads is now %d" % tailcount
else:
tailcount += 1
print "tails! the number of tails is now %d" % tailcount
print "press 'Q' to quit",
userinput = raw_input("or another key to toss again:")
print " the total number of heads:", headcount
print "the total number off tails:", tailcount
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20130925/fe32e4f0/attachment-0001.html>
More information about the docs
mailing list