首页 > 解决方案 > (Python 3.8) How can I turn a variable into a list without a seperator?

问题描述

I want to have a user input a number, and that number is turned into a list named digits. I need to be able to do this without any seperators like space or comma...

number=int(input())
digits=[]

#

print (digits)

Example:
User input: 808
Code output: [8,0,8]

标签: pythonlist

解决方案


Try this:

list(map(int, input()))

推荐阅读