In python Im writing code to extract string from alphanumeric characters. The code should extract only string and print in the following format.
Input should be given in the form of IND1234AUS1234 (i.e Characters must be separated by few digits)
For the above input python code should extract string IND and AUS and print as IND to AUS
Input must not given in any other formats other than mentioned above and if given in wrong format, code should print invalid input. (example of wrong formats of inputs are 1234INDAUS, IND1234, 123IND123AUS, INDAUS1234)
Below is the code i have tried. It extracts string but I don't know how to seperate and print as IND to AUS
My program prints only INDAUS
test_string = input()
only_alpha = ""
for char in test_string:
if char.isalpha():
only_alpha += char
print(only_alpha)
Please help me with the code. I don't know to write code for validating invalid inputs as i mentioned above.
re.findall([A-Z]+,your_string)