Create a list , Just use different data items separated by commas square brackets [ ]
Just round it up .
The data items of a list do not need to have the same type .
list1 = ["qing", "ping", 27]
list2 = [1, 2, 3, 4]
list3 = ["a", "b", "c"]
L1=[10,20,"PYTHON"]
print(L1)
[10, 20, ‘PYTHON’]
# Slice marking method
print(L1[2])
PYTHON
print(L1[1:3])# Less than 3
[20, ‘PYTHON’]
# Negative index
print(L1[-1])
PYTHON
# List length
print(len(L1))
3
# List splicing
L2=[10,90,"java"]
print(L1+L2)
[10, 20, ‘PYTHON’, 10, 90, ‘java’]
#append Finally, add the element
L2.append("docker")
print(L2)
[10, 90, ‘java’, ‘docker’, ‘docker’, ‘docker’]
#apend And for Loop to create a list
list1=[]
for i in range (1,10):
list1.append(i)
print (list1)
[1, 2, 3, 4, 5, 6, 7, 8, 9]
#del Delete an element
del L2[3]
print(L2)
[10, 90, ‘java’, ‘docker’]
#pop eject
L2.pop()
print(L2)
[10, 90, ‘java’]
# Specify an element to pop up
L2.pop(0)
print(L2)
[90, ‘java’]
#sort Sort From small to large
L3=[7,2,3,78]
L3.sort()
print(L3)
[2, 3, 7, 78]
#sorted Temporary sort
L3=[10,3,4,6,7,2]
print(sorted(L3))
print(L3)
[2, 3, 4, 6, 7, 10]
[10, 3, 4, 6, 7, 2]
# Descending order
L3=[7,2,3,78]
L3.sort(reverse=True)
print(L3)
[78, 7, 3, 2]
#count Count the number of times an element appears
L3.count(7)
1