I'm trying to generate a random integral and assign it to the variable.
import random
import time
Op = lambda: random.randint(1300, 19000)
op = "http://ift.tt/2m84JPr"
variable = int(Op())
grow = 0
while x < 3:
print(Op())
grow = grow + 1
time.sleep(1)
In here everything works fine, function "print" prints different result every time with 3 attempts. However when I want to format this code like this:
Op = lambda: random.randint(1300, 19000)
op = "http://ift.tt/2m84JPr"
Op1 = int(Op())
pop = str("{}{}").format(op, Op1)
grow = 0
while grow < 3:
print(pop)
grow = grow + 1
time.sleep(1)
Then the function print gives me the same number three times.
For example:
>>>http://ift.tt/2mPBYLI
>>>http://ift.tt/2mPBYLI
>>>http://ift.tt/2mPBYLI
And I would like to get three random numbers. For example:
>>>http://ift.tt/2m80pzE
>>>http://ift.tt/2mPI1Qf
>>>http://ift.tt/2m7TkPt
I was trying to use %s - %d formatting but the result is the same.
Aucun commentaire:
Enregistrer un commentaire