[Pythonmac-SIG] Some test code

John Parker parkjv1 at gmail.com
Thu Feb 3 04:23:34 CET 2011


All,

I have written this test code

if (card == "Hearts" or card == "Diamonds"):
     print "That card is Red"
     
elif (card == "Spades" or card == "Clubs"):
     print "That card is Black"

It seems to work but prior to this code, it looked like this

if (card == "Hearts" or card == "Diamonds"):
     print "That card is Red"
     
elif (card == "Spades" or card == "Clubs")
     print "That card is Black"

Which didn't work.  Can someone set me straight because in class

The teacher gave an example like this which worked
 if (favcolor == "Red"):
    print "Roses are Red"
    
 elif (favcolor == "Blue"
    print "Violets are Blue"
       

So, why did I have to add a second : after my code for spades or clubs?

Thanks,

John
Python newbie





More information about the Pythonmac-SIG mailing list