Answers for "split numbers python string"

3

splitting a number into digits python

>>> n = 43365644 
>>> digits = [int(x) for x in str(n)]
>>> digits
[4, 3, 3, 6, 5, 6, 4, 4]
>>> lst.extend(digits)  # use the extends method if you want to add the list to another
Posted by: Guest on June-16-2020
0

how to split python string into N numbers equally

import textwrap
print(textwrap.wrap("123456789", 2))
#prints ['12', '34', '56', '78', '9']
Posted by: Guest on September-21-2021

Python Answers by Framework

Browse Popular Code Answers by Language