[#the computer will select a random number from 1 to 3
#first the draws ...
#then the player wins ...
#then the computer wins ...
#then invalid entries
#then use up one round
while rounds != rounds_required:
mighty = random.randint(1, 3)
choice = input("What'sss your choisssce? ")
if choice == "paper" and mighty == 1 or choice == "scissors" and mighty == 2 or choice == "stone" and mighty == 3:
print "Amazzzingly you and the Mighty Python think alike ... "
rounds = rounds + 1
elif choice == "scissors" and mighty == 1:
print "Aaah, your scissorsss cut my Mighty paper !!"
player = player + 1
rounds = rounds + 1
elif choice == "stone" and mighty == 2:
print "Youch, your pesssky ssstone blunted my Mighty ssscissorsss !!"
player = player + 1
rounds = rounds + 1
elif choice == "paper" and mighty == 3:
print "Hisss ... my Mighty ssstone wasss wrapped by your creepy paper !!"
player = player + 1
rounds = rounds + 1
elif choice == "scissors" and mighty == 3 or choice == "paper" and mighty == 1 or choice == "stone" and mighty == 2:
print "Hah! The Mighty Python triumphsss!!!"
python = python + 1
rounds = rounds + 1
else:
print "Invalid attempt ... please type all lower cassse and check your ssspelling."
#announce the final scores
if player == python:
print "You were a worthy challenger we both scored", player," the true winner wasss the game."
elif player > python:
print "I sssalute your random cunning you beat me by", player, " pointsss to", python, "."
else:
print "The Mighty Python triumphsss by", python, " points to a mere", player, "pointsss!"]
I thought it might be the way I have herded together all those "and" and "or" commands but I rewrote it as 9 different elifs and got the same outcome. Of course that doesn't necessarily mean that the "and"s and "or"s are any good themselves does it?
This post has been edited by modi123_1: 04 February 2013 - 03:18 PM
Reason for edit:: highlight the text and just click the 'code' button in the text editor

New Topic/Question
Reply



MultiQuote





|