so I don't get something and would like some help in figuring this out as I can't seem to find anything of use googling around.
I have the following function in a .py file:
def rng(start, stop):
if start == stop:
return random.choice([start, stop])
elif stop < start:
return random.randrange(stop, start)
else:
return random.randrange(start, stop)
Then in another .py file I go ahead, import it and do a print like so:
from random_generator import rng
print(rng(10, 100))
What I don't understand is why do I get 2 numbers printed instead of one? I've been looking into this but am unable to find an answer. If doing the same thing in the random_generator.py file I get only one number, but if importing the function it outputs 2 numbers..
# Output when doing the print in random_generator:
55
# Output when doing the print via importing the rng function in another .py file:
12
44
Edit: There is no other print function in the random_generator.py file, I have deleted the print function after testing this thing.
Aucun commentaire:
Enregistrer un commentaire