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
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
splitting a number into digits python
>>> n = 43365644
>>> [int(d) for d in str(n)]
[4, 3, 3, 6, 5, 6, 4, 4]
>>>
split int and string in python
Python3 code to demonstrate working of
# Splitting text and number in string
# Using re.compile() + re.match() + re.groups()
import re
# initializing string
test_str = "Geeks4321"
# printing original string
print("The original string is : " + str(test_str))
# Using re.compile() + re.match() + re.groups()
# Splitting text and number in string
temp = re.compile("([a-zA-Z]+)([0-9]+)")
res = temp.match(test_str).groups()
# printing result
print("The tuple after the split of string and number : " + str(res))
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us