0

Why do I get a DeprecationWarning when I enter an integer in the random.randrange() function? DeprecationWarning: non-integer arguments to randrange() have been deprecated since Python 3.10 and will be removed in a subsequent version

import random

num = 500

a = random.randrange(-num / 2, num / 2) ## warning
a = random.randrange(-500 / 2, 500 / 2) ## warning
a = random.randrange(-num, num)
a = random.randrange(-250, 250)

When I first entered the code, I entered it as the first case and a warning message was printed. So I found out that I had to enter an integer through a search.

But I tried a few cases because I was wondering why the warning message was printed when all the values I entered were integers.

Through this example, I thought that if you put a calculation expression into a function, a warning will be generated.

Then, how do I not generate a warning message while outputting an arbitrary integer value?

0 Answers0