Converting integer to digit list

前端 未结 10 1108
渐次进展
渐次进展 2020-11-30 23:45

What is the quickest and cleanest way to convert an integer into a list?

For example, change 132 into [1,3,2] an

10条回答
  •  鱼传尺愫
    2020-12-01 00:14

    >>>list(map(int, str(number)))  #number is a given integer
    

    It returns a list of all digits of number.

提交回复
热议问题