Fourteenth day of learning Python tuple []

Nested list:

 Modify the list can be extracted

 Tuples can not be modified, can be read:

NAME1 = [ " the Mac " , " Book " , " Bike " , " Kindle " ] 

A = [[ . 1 , 2 , . 3 ], " Wahaha " , . 4 , ( 2 , . 5 , . 8 , . 6 , . 8 )] # Total list 
Print (a [ 0 ]) # 0 of the list takes the position (he is a small list) [ . 1 , 2 , . 3 ] 
Print (a [ 0 ] [ . 1]) # Take a small list brother position take out an element number 2 
A [ 0 ] [ 1 ] = . 4    # to the position of the re-assignment modify his 
Print (A [ 0 ]) # [ 1 , . 4 , . 3 ] 2 4 was assigned to the 
Print (a [ 3 ] [ 3 ]) # 3 number on the list of locations brother take a small list in a third position   6 
              # is a tuple that can only be read, can not be changed!
[1, 2, 3]
2
[1, 4, 3]
6

  

Guess you like

Origin www.cnblogs.com/hanhankeji/p/11977479.html