## how can i add two randome numbers

This is the place for queries that don't fit in any of the other categories.

### how can i add two randome numbers

ive tried making dice and ive succeeded except for adding the two random numbers(the two rolled dice) to add up the sum of the dice

here is what i have so far:
Code: Select all
`import randommin=1max=12roll_again = 'yes'while roll_again == 'yes' or roll_again == 'y':    print ('shake, shake, shake!')    print ('you got a:')    print random.randint(min,max)    print random.randint(min,max)    print ('the sum of your two numbers are below:')    roll_again = raw_input ('roll the dice again')`
drewster1123

Posts: 8
Joined: Wed Jun 11, 2014 10:19 pm

### Re: how can i add two randome numbers

Hello drewster1123, welcome to the forum. Be sure to read user guideline.

Code: Select all
` print random.randint(min,max)`
assign the result of throwing the die to a variable:

Code: Select all
`die1 = random.randint(min,max)die2 = random.randint(min,max)`

Then you can print them separately, print the sum, etc.

Good luck!

Crimson King

Posts: 166
Joined: Fri Mar 08, 2013 2:42 pm
Location: Dublin, Ireland

### Re: how can i add two randome numbers

thanks Crimson King but how would you print out the sum of the two dice. i assigned dice1 and dice2 to a random number i just need it to print out the sum of both added together
drewster1123

Posts: 8
Joined: Wed Jun 11, 2014 10:19 pm

### Re: how can i add two randome numbers

k i figured it out but when i repeat it (because in my code you have a choice to roll again)it sais the same numbers over and over. so it picks a random number the first time but if you repeat it it sais the same thing

this is what i have so far

Code: Select all
`import randommin=1max=12roll_again = 'yes'die1=random.randint(min,max)die2=random.randint(min,max)while roll_again == 'yes' or roll_again == 'y':    print ('shake, shake, shake!')    print ('you got a:')    print die1    print die2    print ('the sum of your two numbers are below:')    print die1 + die2    roll_again = raw_input ('roll the dice again')    `
drewster1123

Posts: 8
Joined: Wed Jun 11, 2014 10:19 pm

### Re: how can i add two randome numbers

drewster1123 wrote:k i figured it out but when i repeat it (because in my code you have a choice to roll again)it sais the same numbers over and over. so it picks a random number the first time but if you repeat it it sais the same thing

this is what i have so far

Code: Select all
`import randommin=1max=12roll_again = 'yes'die1=random.randint(min,max)die2=random.randint(min,max)while roll_again == 'yes' or roll_again == 'y':    print ('shake, shake, shake!')    print ('you got a:')    print die1    print die2    print ('the sum of your two numbers are below:')    print die1 + die2    roll_again = raw_input ('roll the dice again')    `

You get that output because the throw of the dice is outside the while loop. Put the
Code: Select all
`die1=random.randint(min,max)die2=random.randint(min,max)`
after the 'you got a:' print and it should be fine.

Crimson King

Posts: 166
Joined: Fri Mar 08, 2013 2:42 pm
Location: Dublin, Ireland

### Re: how can i add two randome numbers

ok thank you
drewster1123

Posts: 8
Joined: Wed Jun 11, 2014 10:19 pm