Post

@PythonPr Answer: A) ['a', 'b', 'c']
In Python, the += operator, when used with a list, acts like the list.extend() method. The extend() method iterates over its argument and adds each individual item to the list in-place.
Initial list: x is assigned the list ['a', 'b'].
English

@PythonPr Answer: A → ['a', 'b', 'c']
+= on a list uses extend, and a string is iterable.
So 'c' is added as a single element, not nested or concatenated as a string.
English

Answer: A/C/D) ['a', 'b', 'c'] (all identical!)
How += works with lists:
› x += 'c' iterates over 'c' (a string)
› Strings are iterable, so it takes each char
› 'c' has one char so it appends 'c' to list
› Result: ['a', 'b', 'c']
For beginners: x += 'c' equals x.extend('c'). Want nested? Use x.append('c')
English

@PythonPr There is typo error in your answer ['a', 'b', 'c'] instead of ['a', 'b' , 'c]
A) ['a', 'b', 'c']
x is a list of two elements. += operator extends the list with whatever comes on right side. like equivalent to x.extend(....).
English

@PythonPr None of the above is correct..
Correct answer is ['a', 'b', 'c']
English

@PythonPr A, B, C, and D all have syntax errors ('c instead of 'c'). None of them can be the right answer.
English


















