how to separate a string into 2 lists of numbers and letters python code example
Example 1: how to separate a string into 2 lists of numbers and letters python
stringtosplit = 'hello75world'
letters = []
numbers = []
for k in stringtosplit:
if k.isalpha() == True:
letters.append(k)
elif k.isdigit() == True:
numbers.append(k)
letters = ''.join(letters)
numbers = ''.join(numbers)
print(numbers)
print(letters)
Example 2: how to separate a string into 2 lists of numbers and letters python
stringtosplit = 'hello75world'
letters = []
numbers = []
for k in stringtosplit:
if k.isalpha() == True:
letters.append(k)
elif k.isdigit() == True:
numbers.append(k)
letters = ''.join(letters)
numbers = ''.join(numbers)
print(numbers)
print(letters)