Re: Python Dice Game/Need help with my script/looping!

2016-11-03 Thread Constantin Sorin
I use Linux and python 2.7.12
-- 
https://mail.python.org/mailman/listinfo/python-list


Python Dice Game/Need help with my script/looping!

2016-11-03 Thread Constantin Sorin
Hello,I recently started to make a dice game in python.Everything was nice and 
beautiful,until now.My problem is that when I try to play and I win or lost or 
it's equal next time it will continue only with that.
Exemple:
Enter name >> Sorin
Money = 2
Bet >> 2
You won!
Money 4
Bet >> 2
You won!
and it loops like this :/

Here is the code:

import time
import os
import random
os = os.system
os("clear")

print "What is your name?"
name = raw_input(">>")

def lost():
print "Yoy lost the game!Wanna Play again?Y/N"
ch = raw_input(">>")
if ch == "Y":
game()
elif ch == "N":
exit()



def game():
os("clear")
a = random.randint(1,6)
b = random.randint(1,6)
c = random.randint(1,6)
d = random.randint(1,6)
e = a + b
f = c + d
money = 2
while money > 0:
print "Welcome to FireDice %s!" %name
print "Your money: %s$" %money
print "How much do you bet?"
bet = input(">>")
if e > f:
print "you won!"
money = money + bet
elif e < f:
print "you lost"
money = money - bet
else:
print "?"

print money
lost()  

game()
-- 
https://mail.python.org/mailman/listinfo/python-list