Is list a function in Python?

print[list[range[10]]] print[list[range[1,11]]] print[list[range[51,56]]] print[list[range[1,11,2]]]

Result

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] [51, 52, 53, 54, 55] [1, 3, 5, 7, 9]

This article is extension of below articles :
Python List
List Methods in Python | Set 1 [in, not in, len[], min[], max[]…]
List Methods in Python | Set 2 [del, remove[], sort[], insert[], pop[], extend[]…]

Adding and Appending

  • append[]: Used for appending and adding elements to List.It is used to add elements to the last position of List.
    Syntax:  list.append [element]

    List = ['Mathematics', 'chemistry', 1997, 2000]

    List.append[20544]

    print[List]

    Output:

    ['Mathematics', 'chemistry', 1997, 2000, 20544]
  • insert[]: Inserts an elements at specified position.
    Syntax:

    list.insert[

Chủ Đề