-2

I'm a newbie to python and trying to figure this part out. I would like to rearrange this list with sublists from this:

holidays = [  ["Finland","Europe","12D9N Winter Wonderland Finland",4899],
["Switzerland","Europe", "11D8N Swiss Alps Ski Fun",3698],
["Germany","Europe", "11D8N German Beer and Food Feast",4697],
["Los Angeles (LA)","USA", "9D7N Disneyland Hollywood Fantasy",4799],
["Korea","Asia","8D7N Train to Busan",6789],
["Kuala Lumpur","Asia","4D3N Makan and Shopping Getaway",2899]
]

to something like this:

holidays = [  ["Finland","Switzerland","Germany","Los Angeles (LA)","Korea","Kuala Lumpur",4899],
["Europe","Europe","Europe","USA","Asia","Asia", 3698],
["12D9N Winter Wonderland Finland","11D8N Swiss Alps Ski Fun","11D8N German Beer and Food Feast","9D7N Disneyland Hollywood Fantasy","8D7N Train to Busan","4D3N Makan and Shopping Getaway"],
[4697,4799,6789,2899]
]

How should I do it? Please help! :X

1 Answers1

0
h = [[l[i] for l in holidays] for i in range(len(holidays[0]))]

or

h = list(map(list, zip(*holidays)))
John Giorgio
  • 634
  • 3
  • 10