Hey all,
 
I wrote a rock, paper, scissors game and every time you play without exiting, 
it chooses the same number. How can I fix this problem? The relative code is 
below:
 
[code]
# -*- coding: cp1252 -*-from random import *
print "Welcome to Rock, Paper, or Scissors!"print "by Nathan Pinno"print "© 
2007. All rights reserved."printwhile 1:    answer = int(raw_input("Would you 
like to play a game? 1 for yes and 2 for no. "))    if answer == 1:        
compchoice = choice(range(3))        humanchoice = int(raw_input("Enter 1 for 
rock, 2 for paper, and 3 for scissors. "))        if compchoice == 1:           
 print "AI chose rock."            if humanchoice == 1:                print 
"You chose rock. Tie game."            elif humanchoice == 2:                
print "You chose paper. You win!"            elif humanchoice == 3:             
   print "You chose scissors. You lost!"            else:                print 
"That's not an option. Choose again."        elif compchoice == 2:            
print "AI chose paper."            if humanchoice == 1:                print 
"You chose rock. You lost!"            elif humanchoice == 2:                
print "You chose paper. Tie game."            elif humanchoice == 3:            
    print "You chose scissors. You win!"            else:                print 
"That's not an option. Choose again."        else:            print "AI chose 
scissors."            if humanchoice == 1:                print "You chose 
rock. You win!"            elif humanchoice == 2:                print "You 
chose paper. You lost!"            elif humanchoice == 3:                print 
"You chose scissors. Tie game."            else:                print "That's 
not an option. Choose again."    elif answer == 2:        break    else:        
print "That's not an option."print "Goodbye."[/code]
 
Thanks,
Nathan Pinno
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to