with open("test.txt",'r') as FA: for line in FA: line = line.strip() print("".join(i for i in line[-2:]))