# dice game

2 Players game, you roll a dice that contains numbers from 1->6 for each number a surprise :). First To 10 wins
user_4762113
python
a year ago
2.8 kB
0
Indexable
Never
```import random
import time

def main():
def Player_Check(Player,p):
chances=2
print('===================')
print('it\'s',Player,'\'s Turn')
print('===================')
r=input('Press The First Letter OF Your Name To Throw The Dice\nYOU HAVE ONLY 3 TRIES\n: ')

while chances>0:
if r.lower() != p and r.upper() != p:
r=input('Try Again: ')
else:
break
chances-=1
if chances ==0 and r.lower() != p and r.upper() != p:
print('You Lost',y,'WON')
repeat()

def condition(c,D):
if c==2 or c==6 or c==8:
print('Move 2 Steps')
return c +2
elif c==3 :
return c - D
elif c == 4:
print('Move 1 step Backward')
return c - 1
elif c==5 or c==7 or c>10:
print('Go Back To Position 1')
return 1
elif c==9:
print('Move 4 Steps backward')
return c - 4
elif c==10:
print('You Won')
return c

print('First To 10 Game')
x=input('Enter The First Player\'s name: ')
y=input('Enter The Second Player\'s name: ')
z=x[0]
w=y[0]
s=[1,1]
old1=s[0]
old2=s[1]
rounds=1
while s[0]<=10 or s[1]<=10:
print('-------------------')
print('      ROUND',rounds)
print('-------------------')

Player_Check(x,z)
d=random.randint(1,6)
old1=s[0]
s[0] += d

print('Rolling The Dice . . .')
time.sleep(1)
print('You Got',d)

a=condition(s[0],d)
print('Old Position=',old1)
print('New Position=',a)
s[0]=a

Player_Check(y,w)
d2=random.randint(1,6)
old2 = s[1]
s[1] += d2

print('Rolling The Dice . . .')
time.sleep(1)
print('You Got',d2)
b=condition(s[1],d2)
print('Old Position=',old2)
print('New Position=',b)
s[1]=b

if a==10:
print('GAME OVER',x,'Finished First!')
print('It Took',x,rounds,'Rounds To Win')
repeat()
elif b==10:
print('GAME OVER',y,'FINISHED First!')
print('It Took',y,rounds,'Rounds To Win')
repeat()
rounds += 1

def repeat():
q='Repeat'
while True:
Q=input('Type \'Repeat\' To Play Again: ')
if Q ==q:
main()
else:
print('GoodBye')
exit()
main()
repeat()```