当前位置:网站首页>How to turn a multi digit number into a digital list
How to turn a multi digit number into a digital list
2022-07-06 20:38:00 【huaMinPython】
n=19
Method 1:
1. First convert numbers into strings .str(n)
2. Then convert the string into a string list .list(str)
3. Finally, convert each element into int.【int(i) for i in list】
l=[int(i) for i in list(str(n))]
Method 2:
use map(int,【】) function
l=list(map(int,list(str(n))))
n=19
# Method 1
#l=[int(i) for i in list(str(n))]
# Method 2
l=list(map(int,list(str(n))))
print(l)
边栏推荐
- Anaconda安裝後Jupyter launch 沒反應&網頁打開運行沒執行
- B-杰哥的树(状压树形dp)
- Tencent T4 architect, Android interview Foundation
- BeagleBoneBlack 上手记
- Rhcsa Road
- 【每周一坑】信息加密 +【解答】正整数分解质因数
- 动态切换数据源
- Number of schemes from the upper left corner to the lower right corner of the chessboard (2)
- Mécanisme de fonctionnement et de mise à jour de [Widget Wechat]
- PHP online examination system version 4.0 source code computer + mobile terminal
猜你喜欢
随机推荐
Groovy basic syntax collation
Mécanisme de fonctionnement et de mise à jour de [Widget Wechat]
Intel 48 core new Xeon run point exposure: unexpected results against AMD zen3 in 3D cache
【Yann LeCun点赞B站UP主使用Minecraft制作的红石神经网络】
Is it difficult for small and micro enterprises to make accounts? Smart accounting gadget quick to use
APS taps home appliance industry into new growth points
Leetcode question 448 Find all missing numbers in the array
Basic knowledge of lists
RT thread I2C tutorial
Recyclerview not call any Adapter method :onCreateViewHolder,onBindViewHolder,
Build your own application based on Google's open source tensorflow object detection API video object recognition system (IV)
5. Nano - Net in wireless body: Top 10 "is it possible?" Questions
【GET-4】
OLED屏幕的使用
Dynamically switch data sources
Unity load AB package
JMeter server resource indicator monitoring (CPU, memory, etc.)
C language games - minesweeping
棋盘左上角到右下角方案数(2)
Force deduction brush question - 98 Validate binary search tree