How to convert a list to a list of tuples?

后端 未结 7 1773
陌清茗
陌清茗 2020-11-27 02:52

I am newbie to Python and need to convert a list to dictionary. I know that we can convert a list of tuples to a dictionary.

This is the input list:



        
7条回答
  •  情书的邮戳
    2020-11-27 03:38

    The below code will take care of both even and odd sized list :

    [set(L[i:i+2]) for i in range(0, len(L),2)]
    

提交回复
热议问题