Answers for "split string and convert to int python"

0

split string and convert to int python

a, b = tuple(int(x) for x in '1 2'.split())
Posted by: Guest on October-08-2020
0

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))
Posted by: Guest on June-11-2021

Code answers related to "split string and convert to int python"

Python Answers by Framework

Browse Popular Code Answers by Language