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?
3 Réponses
+ 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
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