python - (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]
解决方案
Try this:
list(map(int, input()))
推荐阅读
- tensorflow - Tensorflow 图执行忽略了更急执行模式下的相等条件
- vb.net - short if statement in VB.Net
- node.js - How do you process the process id of a fork in a node.js application?
- python-3.x - how to aggregate information in one column of dataframe in python3?
- r - 如何强制 R 中的 Hmisc 包舍入到小数点后 3 位?
- caching - 在 IKS 上设置 RedisCache
- java - 为什么在 AMD GPU 上运行的 Aparapi 内核允许非常大的 @Local 数组,但不支持 Nvidia?
- django - Django formset - 自定义输入 HTML
- c++ - 错误 C4716 'Party::operator+': 必须返回一个值
- php - 在 Code Igniter 中使用和条件从多个日期列中选择数据