def display_positive_indices(strlen): print() print(\' \', end=\'\') for i in range(strlen + 1): print(i, end=\'\') if i != strlen:
Since you require an integer you can coerce it to the type you would like, and if it cannot be converted you will get a TypeError or ValueError:
... strlen = int(strlen) for i in range(strlen + 1): ...