10. List
# List List simultaneously storing a lot of data # positive index index 0 . 1 2 # Negative - . 3 - 2 - . 1 fruits1 = [ " Apple " , " Orange " , " PEAR " ] # Boolean list of supported numeric string exist fruits2 = [ " the Apple " , " Orange " , " pear " , " 100 " , True] Print (fruits1) # list by index to find the pear Print (fruits1 [ 2 ]) Print (fruits1 [ - . 1 ]) Print (fruits2) # Slice Slice [start: end) Print (fruits2 [ . 1 : . 4 ]) # [ ' Orange ' , ' PEAR ' , ' 100 ' ] # replace value list fruits1 [ 0 ] = " Grape " Print (fruits1)
run results:
11. tuple
Once the tuple # tuple element can not be modified or deleted COM = ( " Google " , " Microsoft " , " alibaba " , " Tencent " ) Print (COM [ 0 ])
run results: