Aug 25, 2024
nums = [25, 12, 636, 95, 14]
nums[0]
returns 25
nums[-1]
returns 14
nums[2:]
returns [636, 95, 14]
nums[-5]
returns 25
).values = [9.5, "My Name", 25]
mil = [nums, names]
mil
contains both numbers and strings.append(value)
: Adds an element at the end.insert(index, value)
: Inserts an element at a specific index.remove(value)
: Removes the first occurrence of a value.pop(index)
: Removes and returns an element at a specific index (or last element if no index is provided).clear()
: Clears all elements from the list.extend([values])
: Adds multiple elements to the end of the list.nums.append(45)
nums.insert(2, 2077)
nums.remove(14)
del nums[2:]
: Deletes all elements from index 2 to the end.min(nums)
: Returns the minimum value in the list.max(nums)
: Returns the maximum value in the list.sum(nums)
: Returns the sum of all elements.sort()
: Sorts the elements of the list in ascending order.