Hi,
My idea is to check every characters of the whole string and divide them into letters and numbers
Here it is the script:
You can do it with strings directly:
a = 'PIW346'
numbers = ''
letters = ''
for x in range(len(a)):
if a[x].isnumeric():
numbers += a[x]
elif a[x].isalpha():
letters += a[x]
elif a[x] == '.':
bit_value = a[x+1]
break
print numbers
print letters
print bit_value
or you can do it with lists:
a = 'M300.0'
numbers = []
letters = []
for x in range(len(a)):
if a[x].isnumeric():
numbers.append(a[x])
elif a[x].isalpha():
letters.append(a[x])
elif a[x] == '.':
bit_value = a[x+1]
break
print numbers
print letters
print bit_value
I tested it with all the “possibilities” you gave us in the post and it worked all the time.
Hope this will help you
Cheers,