Computer Science, asked by Saipreeth9724, 11 months ago

Describe list() with its syntax.

Answers

Answered by RewelDeepak
1

Answer:

List Methods in Python | Set 2 (del, remove(), sort(), insert(), pop(), extend()…) append(): Used for appending and adding elements to List.It is used to add elements to the last position of List. # Adds List Element as value of List. insert(): Inserts an elements at specified position

Answered by NirmalPandya
1

List, in python, is a data structure which is ordered, mutable, and allows non-homogenous element type.

Describe list() with its syntax.

  • List can look like:
  1. [ ] - empty list
  2. [ 1, 2, 3 ] - list with element type integer
  3. [ 'a', 'b', '1' ] - list with element type string ( '1' is treated as string in python)
  4. [ 'a', 1, [1,2,3] ] - list with mixed element type

  • There are various function which can be applied on list. e.g.
  1. append() Adds an element at the end of the list
  2. clear() Removes all the elements from the list
  3. copy() Returns a copy of the list
  4. count() Returns the number of elements with the specified value
  5. extend() Add the elements of a list (or any iterable)
  6. index() Returns the index of the first element with the specified value
  7. insert() Adds an element at the specified position
  8. pop() Removes the element at the specified position
  9. remove() Removes the first item with the specified value
  10. reverse() Reverses the order of the list
  11. sort() Sorts the list

Similar questions