if i have a list of lists like this one: (the one i have is obviously much larger but this is the idea):
new = [['dog',2],['cat',5],['bye',1]]
...
how can i sort it according to the numbers on the second column, i.e., new[0][1]=2....?
i.e., new.sort should become: new.sort(sthg) = [['bye',1],['dog',2],['cat',5]]
How can i access all the numbers in the second column together like it was a vector?
i.e., new[sthg][sthg] = [2,5,1]
How would you sort it alphabetically up/down?
i.e., alphabetically up: new.sort should become: new.sort(sthg) = [['bye',1],['cat',5],['dog',2]]
i.e., alphabetically down: new.sort should become: new.sort(sthg) = [['dog',2],['cat',5],['bye',1]]
Another basic question:
if i have a list L, L[:] means what?????
I am a newbie in python...
Thanks for the help,
Daniel
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.