Post

Python Programming
Python Programming@PythonPr·
Python Question / Quiz; What is the output of the following Python code, and why? Comment your answers below!
Python Programming tweet media
English
18
12
129
13.1K
Himanshu Kumar
Himanshu Kumar@codewithimanshu·
@PythonPr Arey, Python, interesting question! The output depends on how you look at the code, right? Let's discuss this!
English
0
0
0
106
Earnest Codes
Earnest Codes@Earnesto037·
@PythonPr Answer: B). The extend() method in Python adds all the items of an iterable (like a string, list, or tuple) to the end of the current list individually. When a string is used with extend(), each character of the string is treated as a separate element.
English
1
1
14
608
Kakashi
Kakashi@change_devv·
@PythonPr answer would be ['W', 'X', 'Y', 'Z'] extend() functionc takes an iterable and adds each element individually to the list
English
0
0
4
309
Coding Computing Coach
Coding Computing Coach@CodingComputing·
@PythonPr Answer: B Solution: Let's take a look at what `extend` list method does. Here we start with a list `li`, initialized to ['W']. Now we run the `.extend` list method, with the argument 'XYZ' li.extend('XYZ') The `extend` method works by +
English
1
0
3
719
Timothy Okoye
Timothy Okoye@TimothyOkoye5·
@PythonPr B , the extend method adds individual item to the list
English
0
0
1
194
Vadym Petryshyn
Vadym Petryshyn@vadympetryshyn·
@PythonPr C. And if someone says "I use Python" but doesn't understand extend(), they're probably just using ChatGPT as their IDE.
English
0
0
0
150
Paylaş