0

I am newbee on python programming language and I have a problem about accessing list items like this.

My data is data=[[664159, 550946, 1, 1],[665845, 557965, 1, 2],[597173, 575538, 1, 3],[635690, 608046, 1, 5]]

I want to access first two colums of first items that is [664159, 550946] and I am try to this >data[0][0:1] but i get only first colums data that is [664159] result. I havent got any idea for solving it. Can you help me please? What is my wrong?

>data=[[664159, 550946, 1, 1],[665845, 557965, 1, 2],[597173, 575538, 1, 3],[635690, 608046, 1, 5]]

>data[0][0:1]

>>[664159]

  • You want the first two columns? `data[0][0:2]` ? The end of a slice is exclusive, so `0:1` is just the first... while `0:2` gives you up to but not including, so it's the first and second, and so on... – Jon Clements Feb 23 '20 at 11:03
  • thank you jon it solved my problem – Aziz Yucelen Feb 23 '20 at 11:28

0 Answers0