Hi all, I was wondering if someone could help me with this bit of coding. I have set two veriables d1 and d2 to pick a random int of 1 to 10: which I need for in loop but when I run it the same number appear How do I get a differnt verity of numbers during for in loop in Python 3.1.3 please... Thanks for your time.

``````# generate random number a certian number of times
import random
# set vers
d1= random.randint(1 ,10)
d2= random.randint(1,10)
# now print different number 10 times
for count in range(1,11):
print (d1,d2)

#keep getting same numbers when run``````

## All 2 Replies

Create your random numbers inside the loop, something like this ...

``````# generate random number a certain number of times

import random

# now print different number 10 times
for count in range(1,11):
# create random numbers
d1= random.randint(1,10)
d2= random.randint(1,10)
print (d1,d2)``````

Thank that solved it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.