What method (function) should I use in my code to add a new fruit to this list, for example ['apples', 'bananas', 'pears', 'oranges']?

What method (function) should I use in my code to add a new fruit to this list, for example [‘apples’, ‘bananas’, ‘pears’, ‘oranges’]?

what have you tried to use?

also what language is this?

Welcome to the forum @limur

You mentioned a list.

In python you can use the .append() method to add an item to the end of a list.

To insert an item at a specific index you can use the .insert() method. The first argument is the item, the second argument is the index.

Happy coding

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