I found this list of numbers that I have stored in a python document called "test.txt":
1 2
2 3
3 2
4 5
5 2
6 3
7 7
8 2
9 11
10 13
11 2
12 3
13 5
14 17
15 19
16 2
17 23
18 7
19 29
20 3
21 31
22 2
23 37
24 41
25 43
26 47
27 5
28 53
29 59
30 2
And I am trying to remove the first number of every line and put the second number in a list as an integer so it looks like this:
[2, 3, 2, 5, 2, 3, 7, 2, 11, 13, 2, 3, 5, 17, 19, 2, 23, 7, 29, 3, 31, 2, 37, 41, 43, 47, 5, 53, 59, 2]
I have tried this bit of code:
from inspect import currentframe, getframeinfo
frameinfo = getframeinfo(currentframe())
with open("test.py", "rt") as openfile:
new_list = []
for line in openfile:
new_list.append(line.rstrip(str(frameinfo.lineno())))
print(new_list)
But it gives me this error:
Traceback (most recent call last):
File "fileLocation", line 8, in <module>
new_list.append(line.rstrip(str(frameinfo.lineno())))
TypeError: 'int' object is not callable
Does anyone have a solution for this problem?