I just want your opinions about my code. How could I improve it? Is there a better method to do it?
from sys import exit
from random import randint
print "Welcome to the PIN Game 1!"
print "Tell me your name"
user = raw_input('> ')
#asks the user for an entry and prints what he has chosen
def start():
print "%s, choose one of the options: " % user
print """
1. Rock
2. Paper
3. Scissors
"""
choice = 0
cpu_choice = randint(1,3)
while choice <= 0 or choice >= 4:
choice = int(raw_input('> '))
if choice == 1:
print "You chose ROCK!"
elif choice == 2:
print "You chose PAPER"
elif choice == 3:
print "You chose SCISSORS"
else:
print "What is your problem? Try again, this time choose a number between 1 and 3!"
cpu_decision(cpu_choice)
result(choice, cpu_choice)
#random cpu input
def cpu_decision(cpu):
if cpu == 1:
print "Your opponent chose ROCK!"
elif cpu == 2:
print "Your opponent chose PAPER!"
else:
print "Your opponent chose SCISSORS"
#if user loses
def lose():
print "Sorry, you lost the match"
#if user wins
def win():
print "Congratulations! You beat your opponent!!"
#prints the result
def result(user, comp):
if user == comp:
print "Gee! You tied!"
elif user == 1 and comp == 2:
lose()
elif user == 1 and comp == 3:
win()
elif user == 2 and comp == 1:
win()
elif user == 2 and comp == 3:
lose()
elif user == 3 and comp == 1:
lose()
elif user == 3 and comp == 2:
win()
again()
#ask if the user wants to play again
def again():
print """
Wanna play again?
1 for YES
Anything else to quit
"""
again1 = int(raw_input('> '))
if again1 == 1:
start()
else:
exit()
start()