lundi 11 janvier 2021

random.randint error "ValueError: non-integer arg 1 for randrange()"

This is for a Blender 2.9 Addon Script, that might be why this is happening

I have this incredibly simple for loop using a randint and I keep getting a non-int value in my first arg... this is killing me as I can't figure out what I'm doing wrong... :( Does anyone care to help me with this simple problem I'm bagging my head against the wall with?

from random import randint

for _ in range(50):
    x = randint(-20, 20)
    y = randint(-20, 20)
    z = randint(-1, 1)
    print(x, y, z)

Error

Error: Traceback (most recent call last):
  File "C:\Users\vida\AppData\Roaming\Blender Foundation\Blender\2.90\scripts\addons\multiple_files_example\main_operator.py", line 15, in execute
    print(x, y, z)
  File "C:\Program Files\Blender Foundation\Blender 2.90\2.90\python\lib\random.py", line 222, in randint
    return self.randrange(a, b+1)
  File "C:\Program Files\Blender Foundation\Blender 2.90\2.90\python\lib\random.py", line 186, in randrange
    raise ValueError("non-integer arg 1 for randrange()")
ValueError: non-integer arg 1 for randrange()



Aucun commentaire:

Enregistrer un commentaire