That’s what you get is not a mistake! This is the literal value of your function that you get through the code below:
>>> v = randint.__str__() # Devolve uma string
>>> print("\n" + v)
<bound method Random.randint of <random.Random object at 0x0000015E1A1D4FD0>>
There are two problems with your code. The first problem is that you didn’t call the function. To call a function, use the parentheses (open and close parentheses) as in the example below:
var = func()
The second problem of your code, is that you did not pass the necessary arguments to call the function randint()
.
To perform this function, you must pass an initial value and a final value. Thus, the randint
will return a random value between a
and b
, example:
x = randint(0, 3) # Retorna um valor entre 0 e 3
What you were doing in your code was assigning the function randint
to the variable a
, making both functions the same. Example:
a = randint
a is randint # True
randint(0, 3)
a(0, 3) # Posso executá-la assim como no randint já que ambos são idênticos.