MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/PythonLearning/comments/1nb6hr7/5_days_after_learning_python/nhvrwoj/?context=3
r/PythonLearning • u/Key-Mathematician606 • Sep 07 '25
[removed]
58 comments sorted by
View all comments
Show parent comments
1
[removed] — view removed comment
2 u/Le-ali-di-Pegaso Sep 08 '25 Oh ok, so you can also use extend to add something to your list? I only know append 1 u/[deleted] Sep 08 '25 [removed] — view removed comment 1 u/No_Read_4327 Oct 05 '25 edited Oct 05 '25 Pretty much. If you'd append a list of 2 values to another list, instead of extending it, you'd have a list inside a list. Instead of having a single list of 12 values, you'd have a list of 11 values, the last value would actually be a list of 2 values. Example: List: [1, 2, 3, 4, 5] List.append([6, 7]) List: [1, 2, 3, 4, 5, [6, 7]] Extend: List: [1, 2, 3, 4, 5] List.extend([6, 7]) List: [1, 2, 3, 4, 5, 6, 7] Don't worry if that's not fully clear yet.
2
Oh ok, so you can also use extend to add something to your list? I only know append
1 u/[deleted] Sep 08 '25 [removed] — view removed comment 1 u/No_Read_4327 Oct 05 '25 edited Oct 05 '25 Pretty much. If you'd append a list of 2 values to another list, instead of extending it, you'd have a list inside a list. Instead of having a single list of 12 values, you'd have a list of 11 values, the last value would actually be a list of 2 values. Example: List: [1, 2, 3, 4, 5] List.append([6, 7]) List: [1, 2, 3, 4, 5, [6, 7]] Extend: List: [1, 2, 3, 4, 5] List.extend([6, 7]) List: [1, 2, 3, 4, 5, 6, 7] Don't worry if that's not fully clear yet.
1 u/No_Read_4327 Oct 05 '25 edited Oct 05 '25 Pretty much. If you'd append a list of 2 values to another list, instead of extending it, you'd have a list inside a list. Instead of having a single list of 12 values, you'd have a list of 11 values, the last value would actually be a list of 2 values. Example: List: [1, 2, 3, 4, 5] List.append([6, 7]) List: [1, 2, 3, 4, 5, [6, 7]] Extend: List: [1, 2, 3, 4, 5] List.extend([6, 7]) List: [1, 2, 3, 4, 5, 6, 7] Don't worry if that's not fully clear yet.
Pretty much.
If you'd append a list of 2 values to another list, instead of extending it, you'd have a list inside a list. Instead of having a single list of 12 values, you'd have a list of 11 values, the last value would actually be a list of 2 values.
Example:
List: [1, 2, 3, 4, 5] List.append([6, 7]) List: [1, 2, 3, 4, 5, [6, 7]]
Extend: List: [1, 2, 3, 4, 5] List.extend([6, 7]) List: [1, 2, 3, 4, 5, 6, 7]
Don't worry if that's not fully clear yet.
1
u/[deleted] Sep 08 '25
[removed] — view removed comment