Nov-22-2018, 09:04 AM
You should get an error because of line 2. The indentation is wrong.
with open("abc1.txt", "w+") as fw1, open("abc2.txt", "w+") as fw2: for element in p: if len(element.strip('Eth').split('/')[0]) == 1: # if you have one digit before the first / # write to abc1.txt else: # if you a sure that the input is correct else should work if you have three digits before / # write to abc2.txtOr you can use regular expressions. I am not good at it. Never needed it so far :D