string = 'Hello, welcome to my world001'
This is the string which I have been trying to split into two (number and string). The numbers from the back needs to be splitted from the original string. Is there any method in python that can do this real quick.
Here's my try(code):
length_of_string = len(string) - 1
num = []
if string[-1].isdigit():
while length_of_string > 0:
if string[length_of_string].isdigit():
num.insert(0, int(string[length_of_string]))
length_of_string -= 1
print(num)
else:
string += '1'
print(string)