split int and string in python

Solutions on MaxInterview for split int and string in python by the best coders in the world

showing results for - "split int and string in python"
Giulia
02 Mar 2018
1 Python3 code to demonstrate working of
2# Splitting text and number in string 
3# Using re.compile() + re.match() + re.groups()
4import re
5  
6# initializing string 
7test_str = "Geeks4321"
8  
9# printing original string 
10print("The original string is : " + str(test_str))
11  
12# Using re.compile() + re.match() + re.groups()
13# Splitting text and number in string 
14temp = re.compile("([a-zA-Z]+)([0-9]+)")
15res = temp.match(test_str).groups()
16  
17# printing result 
18print("The tuple after the split of string and number : " + str(res))
19