1numbers = []
2animals = []
3with open('textfile.txt') as f:
4 for x in f:
5 try:
6 numbers.append(int(x.replace("\n", "")))
7 except:
8 animals.append(str(x.replace("\n", "")))
9print(numbers)
10print(animals)
11
12# Output
13# [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
14# ['dog', 'cat', 'fish', 'bird']