1: "'
2: arrays have list and tuple points
3: "'
4:
5: classmates=[' A ', ' B ', ' C ', ' d ']
6: print (classmates)
7: Length=len (classmates)
8: print (length) #4
9: print (classmates[0]+classmates[1]) # AB
: #print (classmates[5]) #IndexError: List index out of range
One : print (classmates[-1]) #! The index of the last element is-1
: classmates.append (#在最后加个元素88)
: print (classmates)
: classmates.insert (2,45)
: "'
: Add a 45 to the second position
: "
: print (classmates)
: Classmates.pop (-2)
: "'
Seven : Delete the second-to-last element
A : "'
At : print (classmates)
: a=[[1,2,3],[4,5,6],[7,8,9]]
: print (a)
£ º
:
: "
: Tuple cannot change, once definition cannot be changed. Once a tuple is defined, the element must be fixed.
: "'
: classmates= (' A ', ' B ', ' C ')
: p=[' asp ', ' php '
: s=[' python ', ' Java ', p, ' scheme '
: print (s[2][1])
: a= ()
A : print (a)
Panax notoginseng :#定义只有一个元素的tuple的时候必须在定义后面加一个 ","
: a= (1,)
Section : print (a)
Max : "'
All : output is (1,)
" : "
:
: a= (1)
: Print (a) #输出为1
#但是这样可以变:
A : l= (' A ', ' B ', [up])
: print (L)
: l[2].append (54)
: print (L)
Wuyi: #但这样变的只是L中的tuple.
: L = [
: [' Apple ', ' Google ', ' Microsoft ',
Si : [' Java ', ' Python ', ' Ruby ', ' PHP '],
: [' Adam ', ' Bart ', ' Lisa ']
: ]
£ º print (l[0][0],l[1][1],l[2][2])