Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 710b61e

Browse files
author
Amogh Singhal
authored
Update Python_Programming_Quiz.md
1 parent 2c0592e commit 710b61e

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

‎Python_Programming_Quiz.md‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,3 +282,24 @@ Function | Description |
282282
# step 3 : [-8,5]
283283
-13
284284
```
285+
286+
#### 17. Differentiate between the `append()` and `extend()` methods of a list.
287+
288+
`append()` __adds an element__ to the end of the list <br>
289+
`extend` __adds another list__ to the end of a list.
290+
291+
```
292+
>>> list1, list2 = [1, 2, 3], [5, 6, 7, 8]
293+
294+
# This is how append() works:
295+
296+
>>> list1.append(4)
297+
>>> list1
298+
[1, 2, 3, 4]
299+
300+
And this is how extend() works:
301+
302+
>>> list1.extend(list2)
303+
>>> list1
304+
[1, 2, 3, 4, 5, 6, 7, 8]
305+
```

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /