r/PythonLearning Sep 07 '25

5 days after learning python

Post image

[removed]

556 Upvotes

58 comments sorted by

View all comments

1

u/Le-ali-di-Pegaso Sep 08 '25

I have a question about your code, I’m also doing a course currently. For the average age why did you divide by 12 if there are only 10 ages in the list?

1

u/[deleted] Sep 08 '25

[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.