This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author steven.daprano
Recipients SilentGhost, coldy028, steven.daprano, terry.reedy
Date 2019-05-10.07:17:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1557472624.53.0.0255336145796.issue36872@roundup.psfhosted.org>
In-reply-to
Content
David, I'm pretty sure that SilentGhost is correct. You are misreading the error message: it has nothing to do with the negative index.

The problem is that your `insert_value` function returns None, not the list. I believe that what you have done is tested the function once, with a positive index and then tried it again with a negative index:

    # this works fine, the first time
    str_list4 = list_function.insert_value(str_list4, 's', 1)
    # but fails the second time
    str_list4 = list_function.insert_value(str_list4, 's', -1)

The reason is that functions returns None by default, so you have replaced str_list4 with None. Then on the second call to the function, this line fails:

    for index in my_list:

because my_list is None. When Python gives you an error message, PLEASE READ IT because the interpreter does not lie, it knows what caused the failure:

    TypeError: 'NoneType' object is not iterable

Python is used by hundreds of thousands of people and they probably would have noticed a severe, fundamental flaw like the inability to pass negative numbers to other modules by now. As a beginner, 99.99% of the "bugs" you find will be in your own code, not the language.

(It has been said that the difference between a beginner and an expert is that the beginner assumes every bug is the language's fault, and an expert knows that nearly every bug is his own fault.)

As SilentGhost says, this list is not a help-desk. Please don't follow up with extra questions here, I won't answer. If you want help or advice, please subscribe to the tutor mailing list

https://mail.python.org/mailman/listinfo/tutor

where there will be plenty of people happy to help.

If you still believe that your code is correct, and you've found a bug that has escaped thousands of full-time Python programmers (it does happen...) then please take the time to read this:

http://www.sscce.org/

and follow the advice given there. It's written for Java, not Python ,but the advice applies to any language.

Thank you.
History
Date User Action Args
2019-05-10 07:17:04steven.dapranosetrecipients: + steven.daprano, terry.reedy, SilentGhost, coldy028
2019-05-10 07:17:04steven.dapranosetmessageid: <1557472624.53.0.0255336145796.issue36872@roundup.psfhosted.org>
2019-05-10 07:17:04steven.dapranolinkissue36872 messages
2019-05-10 07:17:04steven.dapranocreate