When we use +=

hello please when we use += like in

list += element

In your case, you’re adding the element to your list list:

lst = ["a", "b", "c", "d"]
lst += "ef"
>>output: ["a", "b", "c", "d", "e", "f"]

Note that in the above example, you can’t use objects such as integers or floats on the right-hand side of the +=; the object you’re adding as to be iterable.

1 Like