This: liste.append(‘d’) or liste=liste+[‘d’]
effectively does the same thing twice. list.append modifies liste in place and returns None.
So the or statement is equal to the second expression, which is then evaluated and assigns the new list to liste. It just so happens that this new list, liste+['d'] would’ve had exactly the same value as the original liste after the single append operation. But it’s an assignment, and in Python the name liste could be re-assigned to anything:
liste.append(‘d’) or liste=["Another", "list", "entirely"]
Adding two lists is like calling list.extend, and list.extend on a length-1 list is essentially an append of the singleton list’s only element.
Admittedly I didn’t install Jupyter to check it’s valid syntax in a worksheet. But I can’t think how else they got two 'd's in there, and as you say yourself you can’t reproduce it.
Jupyter worksheet spaghetti code is another possible cause, with parts of statements causing mutations being run out of sequence or multiple times, regardless of syntax.
Jupyter has global state which you can modify even without meaning to.
It looks like you transformed liste into ['a', 'b', 'c', 'd'] at some point by accident.
After that liste.append('d') would result in liste==['a', 'b', 'c', 'd', 'd'] and liste+['d']; liste would print ['a', 'b', 'c', 'd']
Personally I think Spyder is a better starting point for beginners. It’s harder to make this type of mistake there, and if you do run into trouble there is more of a guarantee that you can copy-paste your code in a way that reproduces your error.
If your teacher uses Jupyter there’s not much you can do about that. (Except complain , maybe they’ll do better next year.)
Jupyter notes the execution order at the left of the cells. Ideally you want to see a sequence like [33] [34] [35] [36] from top to bottom.
You have [24] [28] [32] [34].
That suggests something is messed up and you’re executing all your cells twice when they execute?
I agree with Peter. You are almost certainly executing the cells twice, and the problem is that the new value becomes the starting point for the second execution. One way to check what is happening is to put in one cell the following three statements.
print(liste)
liste = liste + ['e']
print(liste)
That way when you execute the cell you can see the value before and after execution.