I'm an extreme beginner with Python (this game is the first time I have ever seen it) so please bear with me.
Creating a simple dice game. Place a bet. Three dice are rolled, if any are the same value you lose. If you win, you get double your bet.
I've gotten the majority of the game programmed but I cannot figure out how to input the bet data from my xhtml form into the final results.
import cgi form = cgi.FieldStorage() nombre = form.getvalue("nombre") bet = form.getvalue("bet") # print HTTP/HTML headers print """Content-type: text/html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html><head> <title>Dice Game</title> </head><body> """ # print HTML body using form data import random die = random.randint(1,6) die2 = random.randint(1,6) die3 = random.randint(1,6) bet = int( form.getvalue("bet") ) print "<p>Thanks for playing, "+ nombre +". Your roll:</p>" print "<p> %i %i %i.</p>" % (die, die2, die3) if die == die2: print "<p>You lose $%i.</p>" %i (bet) if die2 == die3: print "<p>You lose $%i.</p>" %i (bet) if die == die3: print "<p>You lose $%i.</p>" %i (bet) else: print "<p>You win $&i.</p>" %i(bet*2) print """</body></html>"""
When the game is played, it comes up with the error "NameError: name 'i' is not defined".
I'm sure there's a very simple error I'm making but it's brought my progress to an absolute standstill.
I also have to substitute images for the text numbers and am unsure of how to proceed with that.
Any help would be MUCH appreciated. And for reference, this is how the game should function.