0

Python: a range of integers

It can seem a trivial question, but since range() returns a list of STRINGS, you can't use it in a for iteration: for x in range(1, 10) will raise an error. I tried also numpy.arange() with fourth dtype parameter: import numpy as np [... ] for x in np.arange(1, 10, 1, np.intp) Same error. Any suggestion?

17th Jan 2019, 6:24 AM
Paolo De Nictolis
Paolo De Nictolis - avatar
2 Respuestas
+ 4
range() does not return a range of strings, it's perfectly normal to use range for iteration and for x in range(1, 10) will not raise an error 🤔 Please post the code you're having trouble with
17th Jan 2019, 6:49 AM
Anna
Anna - avatar
0
SOLVED. I didn't cast "num" input to int, so it was passed to function as string: https://code.sololearn.com/cEJX9WYBk1nd/?ref=app Thankx to you all
17th Jan 2019, 7:05 AM
Paolo De Nictolis
Paolo De Nictolis - avatar