>>> import random
>>> random.SystemRandom.randint(0, 10)
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
random.SystemRandom.randint(0, 10)
TypeError: randint() missing 1 required positional argument: 'b'
SystemRandom is supposed to give random numbers though os.urandom
, randint
works like normal randrange
:
>>> print(random.SystemRandom.randint.__doc__)
Return random integer in range [a, b], including both end points.
In IDLE a little popup suggestion appears when I type it it saying
`random.SystemRandom.randint(self, a, b)`
I think this is the cause. I'm not very good at using classes and understanding how they work, but the first argument seems to be being passed as self
, when it should be a
. I never really understand why self
is used when it isn't even a keyword, and how it's supposed to all just work, but it generally does.
Am I doing this wrong, or should I report this to the Python Foundation whenever one is supposed to do such things?
When the error is "TypeError: randint() missing 1 required positional argument: 'b'" it's because the person writing the code probably mixed up their
random.randint()
and their
random.choice()
Hope I helped :D
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With