Len's slice

Struggling to understand how to add the value for peppers in as the code isn’t working due to 2.5 being a decimal number and not an integer but the task states 2.5. Also struggling with how to insert in specific place

Might check the documentation :slightly_smiling_face:

Insert an item at a given position. The first argument is the index of the element before which to insert, so a.insert(0, x) inserts at the front of the list, and a.insert(len(a), x) is equivalent to a.append(x).

For two arguments passed to .insert() the first acts as an index, or were to insert. Meaning a float value will throw an error since in index should be a whole number.

Thank you! That worked, here’s my code for anyone else stuck:

1 Like

That’s excellent to hear! Well done!

Generally though communities like this try not to post the full working code to course content. It might be better to use a spoiler around your image :slightly_smiling_face:

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.