-6

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)
mkrieger1
  • 19,194
  • 5
  • 54
  • 65

1 Answers1

0

You can chain with ;.

Like so:

import random; random.randint(0, 10)

or

import random; a = random.randint(0, 10); print(a)
mkrieger1
  • 19,194
  • 5
  • 54
  • 65