Try:

from random import randrange
print(randrange(10))

Docs: https://docs.python.org/3/library/random.html#random.randrange