Append_size problem


#1

Hithere could someone tell me what I did wrong for this question? Thanks!!


#2

Count the parens in this line. 3 open and only 2 close.

lists

>>> def append_size(lst):
  extend = list(range(1,(len(lst) + 1)))
  lst.append(extend)
  return lst

>>> print(append_size([23, 42, 108]))
[23, 42, 108, [1, 2, 3]]
>>> 
>>> def append_size(lst):
  lst.extend(list(range(1,(len(lst) + 1))))
  return lst

>>> print(append_size([23, 42, 108]))
[23, 42, 108, 1, 2, 3]
>>> 

#3

Thanks Roy, fixed the perens but still not doing what I want!

Question:
https://www.codecademy.com/paths/computer-science/tracks/cspath-flow-data-iteration/modules/dspath-lists/lessons/python-functions-lists-cc/exercises/append-size

Also tried
extend = list(range(1,(len(lst) + 1))) but it’s nesting a separate list rather than just adding the numbers.

Many thanks!!


#4

what is perens?

as you can see in @mtf code samples, .append() will nest a separate list, which is why you need to extend the list. (also in mtf his code sample). Please check his excellent answer


#5

parens is the short form of parentheses (plural).


#6

Really sorry, I missed your answer on that first reply. Makes sense and thanks so much for the help!