Ad
  • Custom User Avatar

    Please, before saying it has nothing to do with your issue, have you tried your code with a single digit number? I've added the if and your code worked.
    Note that in your properly formatted code, you have n_ stand it should be n_st instead.

  • Custom User Avatar

    Your code is failing with single digit numbers. Why did you remove the if?

  • Custom User Avatar

    Mark your post as having spoiler content next time, please. And also, it's a problem with your code, so use Question instead of issue, see how many Python completions there already are:

    Python Completions 2606

    When posting code, try using proper markdown too, because in Python indentation is important.

    If what I think is right this is the output to the console with your code (I had to guess how the indentation was because it was lost):

    ('n is', 12)
    ('Length of n is:', 2)
    ('We are in if', 'i is', 1, 'equal is ', 0, 'remainings are:', '1', '2')
    ('Out of while, i is', 2)
    

    And you can see when you use this:

    idx = inv.index(n_st[-(i+1)])
    

    The index (-3) is out of range.