Updated code using the provided tips:
I have updated my code, I have used a little bit of all of your answers. I appreciate your help a lot! You helped me understand better dictionaires and other concepts. Thanks very much.
from sys import exit
from random import randint
print "Welcome to the PIN Game 1!"
print "Tell me your name"
user = raw_input('> ')
print "%s, choose one of the options: " % user
#Constants
ROCK = 1
PAPER = 2
SCISSORS = 3
names = {ROCK: "ROCK", PAPER: "PAPER", SCISSORS: "SCISSORS"}
#asks the user for an entry and prints what he has chosen
def start():
print """
1. ROCK
2. PAPER
3. SCISSORS
"""
choice = user_decision()
cpu_choice = cpu_decision()
result(choice, cpu_choice)
#user input
def user_decision():
choice = 0
while choice <= 0 or choice >=4:
choice = int(raw_input('> '))
if choice >= 1 or choice <= 3:
print "You chose %s" % names[choice]
else:
print "What is your problem? Try again, this time choose a number between 1 and 3!"
return choice
#random cpu input
def cpu_decision():
choice = randint(1,3)
print "Your opponent chose %s!" % names[choice]
return choice
lose = "Sorry, you lost the match..."
win = "Congratulations, you won!!"
outcomes = {
ROCK: {PAPER: lose, SCISSORS: win},
PAPER: {ROCK: win, SCISSORS: lose},
SCISSORS: {PAPER: win, ROCK: lose}
}
#prints the result
def result(user, comp):
if user == comp:
print "Gee! You tied"
else:
print outcomes[user][comp]
#ask if the user wants to play again
def main():
while True:
start()
print """
Wanna play again?
1 for YES
Anything else to quit
"""
again1 = int(raw_input('> '))
if again1 != 1:
break
main()