How can I import something in Python and use it on the same line? For example import random
and using random.randint(0,10)
on the same line, instead of
import random
random.randint(0, 10)
How can I import something in Python and use it on the same line? For example import random
and using random.randint(0,10)
on the same line, instead of
import random
random.randint(0, 10)
You can chain with ;
.
Like so:
import random; random.randint(0, 10)
or
import random; a = random.randint(0, 10); print(a)