Feb-03-2017, 11:25 AM
Hello everyone.
im new to python , just started before few days and i tried to made a snakes and ladders game.
as you can see in the code below i want that the program will choose a random number between 1-6 untill a player will reach to step 100 and it will be over.
but when the loop is starting every player gets the same random number the program choose at the start of the loop and not different number.
what can i do to make it different number every time to each user?
sorry for my bad english.
im new to python , just started before few days and i tried to made a snakes and ladders game.
as you can see in the code below i want that the program will choose a random number between 1-6 untill a player will reach to step 100 and it will be over.
but when the loop is starting every player gets the same random number the program choose at the start of the loop and not different number.
what can i do to make it different number every time to each user?
sorry for my bad english.
import random dice = random.randint(1,6) user1 = input('Hello,What is user1 name?:') user2 = input('And what is the other user name?:') user3 = input('what the user3 name whould be:)?:') u1step = int(0) u2step = int(0) u3step = int(0) while u1step < 100 or u2step < 100 or u3step < 100 : start = input('Whould you like to roll the dice?: Yes Or No') if start == 'yes' : u1jump = random.randint(1, 6) u2jump = random.randint(1, 6) u3jump = random.randint(1, 6) u1move = u1step + u1jump u1step = u1move u2move = u2step + u1jump u2step = u2move u3move = u3step + u1jump u3step = u3move elif start == 'no' : print('You have ended the game') print(user1, 'is currently on the', u1step) print(user2, 'is currently on the ', u2step) print(user3, 'is currently on the ', u3step) break if u1step >= 100 or u2step >= 100 or u3step >= 100 : print('We have a winner !') print(user1,'is currently on the', u1step) print(user2, 'is currently on the ', u2step ) print(user3, 'is currently on the ', u3step)