On Mon, Feb 8, 2021 at 6:36 AM Philipp Daher via Python-list <python-list@python.org> wrote: > > Hello, > > I recently coded this snippet of code: > myString=„hello“ > for i in range(len(myString): > print(string[i])
This code won't work as is. Please *copy and paste* your code when asking for help. > And now for the weird part: > > SOMETIMES, the output is this: > > hello > > And SOMETIMES, the output changes to: > > ohell Neither of those makes sense based on the code you're showing, so again, please *copy and paste* the code and output. > WHY??? Why do I get different outputs with the EXACT SAME CODE? > > Can someone help me please? Thank you I would recommend that you start by iterating over the string itself, instead of a range. My crystal ball tells me that you're getting tangled with negative indexing, but without seeing the code each time, it's impossible to be sure. ChrisA -- https://mail.python.org/mailman/listinfo/python-list