I\'m getting this strange error trying to run a script, the code appears to be correct but it seems python (3) didn\'t liked this part:
def function(
As other answers have said, range()
being an iterator is your problem, however, a simpler (in my view) solution is to generate the list from -30
to 30
then remove 0
, rather than avoiding it:
choice([i for i in range(-30, 30) if i != 0])
Naturally, if your ranges were more disparate, this might become unwieldy.