Python, last element cut -


well problem original input is:

x=[['1', '7', 'gg'], ['1.5', '8', 'as']...] 

i need cut last element in every row.

i try cut last element in matrix that:

hl=x[:,:-1] 

but not working, try in way:

kl=array(x)  hl=x[:,:-1] 

now get:

[['1' '7']  ['1.5' '8']] 

instead of: [['1' , '7'] ['1.5' , '8']]

any solution?

>>> x=[['1', '7', 'gg'], ['1.5', '8', 'as']] >>> [s[:-1] s in x] [['1', '7'], ['1.5', '8']] 

Comments