Skip to content
PingpingPapa edited this page Mar 6, 2022 · 4 revisions

Function of List

  • sort(): Sorts the list in ascending order.
  • type(list): It returns the class type of an object.
  • append(): Adds one element to a list.
  • extend(): Adds multiple elements to a list.
  • index(): Returns the first appearance of a particular value.
  • max(list): It returns an item from the list with a max value.
  • min(list): It returns an item from the list with a min value.
  • len(list): It gives the overall length of the list.
  • clear(): Removes all the elements from the list.
  • insert(): Adds a component at the required position.
  • count(): Returns the number of elements with the required value.
  • pop(): Removes the element at the required position.
  • remove(): Removes the primary item with the desired value.
  • reverse(): Reverses the order of the list.
  • copy(): Returns a duplicate of the list.

특정 값의 인덱스 찾기

list_a = [1, 1, 1, 2, 3, 4, 5, 6]
print(list_a.index(1))

정렬

array.sort(key = lambda x:x[0])
print(array)
>>>>> [[30, 'banana'], [50, 'apple'], [400, 'melon']]
#기준이 여러 개일 경우
lst.sort(key = lambda x: (-x[1], x[2], -x[3], x[0]))

count values

image

Home

Home

Python Basic
a
Library

bc

Algorithm
b
Clone this wiki locally