I have a list of tuples called list_cs
:
('2015-05-14', 685)
('2015-04-15', 680)
('2015-03-20', 675)
('2015-02-11', 680)
('2015-01-13', 685)
('2014-12-10', 685)
('2014-11-25', 685)
('2014-10-09', 685)
('2014-09-15', 690)
('2014-08-21', 680)
('2014-07-22', 680)
For the first 5 tuples, I want to assign the scores in the second position of the tuple to unique variables. I do it like this:
cs0 = [x[1] for x in list_cs[0:1]]
cs1 = [x[1] for x in list_cs[1:2]]
cs2 = [x[1] for x in list_cs[2:3]]
cs3 = [x[1] for x in list_cs[3:4]]
cs4 = [x[1] for x in list_cs[4:5]]
I also want to assign the score in the second position of the last tuple to a unique variable. I never know how long the list might be; but I just want the last one. But, I can't figure out how to get that last one.
I've tried some of the following but none of them work.
cs1st = [x[1] for x in list_cs[-1:-0]]
cs1st = [x[1] for x in list_cs[-0:-1]]
cs1st = [x[1] for x in list_cs[:-1]]
cs1st = [x[1] for x in list_cs[-1]]
How can I do this?