nmay be numeric, but at some point you go past the length n, so it n[previous:next]doesn't contain characters at all. Empty string ''can not be converted to int, therefore, an error that tells the full story: invalid literal for int() with base 10: ''.
>>> int('')
Traceback (most recent call last):
File "<input>", line 1, in <module>
ValueError: invalid literal for int() with base 10: ''
source
share