Is this possible with pyhton? If it is, how can you do it?

def raise():
    raise = raw_input('Do you really want to raise? y/n')
    if raise == 'y':
        bet = bet+1
        return # Should RETURN to play(), after raise()
               # Like "goto LABEL"
    else:
        return

def play():
     bet = 1
     print 'The computer did a bet of 1 dollar.'
     print 'I raise.'
     raise()  # The 'LABEL'
     print 'The bet now is', bet
     print 'End of the test."

Edited 6 Years Ago by Hawkeye Python: n/a

Here is your code, slightly modified to work. I have passed bet in as a parameter and returned it; and renamed the function to something legal (I recommend using a better name than my choice). Note also the space after the y/n: Not necessary, but much prettier in my opinion.

def rraise(bet):
  rraise = raw_input('Do you really want to raise? y/n ')
  if rraise == 'y':
    bet = bet+1
  return bet
#
def play():
  bet = 1
  print 'The computer did a bet of 1 dollar.'
  print 'I raise.'
  bet = rraise(bet)
  print 'The bet now is', bet
  print 'End of the test.'

play()

You also need some error checking, it's good practice.
Example:

rraise = raw_input("Do you really want to raise? y/n ')
if rraise == 'y':
  bet += 1
elif rraise == 'n':
  pass
else: print "y or n please..."
return bet

Mark thread is solved has moved. You can now find it as a link at the top. Use ctrl+F and search for solved and you should find it. It is next to the bit that says "Python Discussion Thread View First Unread"

Just an FYI for anyone who needs to know.

This article has been dead for over six months. Start a new discussion instead.