Reputation: 29
Using the current code that is below this code will create a random number with a massive amount of decimals. Example: 8.71763761465. I'm guessing that there is a way to generate numbers with no decimal, I just don't know how. How do you generate numbers without massive amounts of decimals? Thank you.
import random
randint = random.uniform(1, 10)
print (randint)
Upvotes: 0
Views: 270
Reputation: 3228
Why not just cast it to an int?
import random
randint = int(random.uniform(1, 10))
print(randint)
Or, more appropriately, just use randint
:
import random
randint = random.randint(1, 10)
print (randint)
Upvotes: 1