-5

I have a file that i want to use python to read it with. The file is in the following format:

12
45
45
78
56
45
67
09
12
45

How can i append all these numbers into a list?!! For example:

x = [12,45,45,78,56,45,67,09,12,45]

I am trying .strip() and .split() methods but i am missing something.

(This is a PPM file i am reading through and not using actual format because i just need to know the method)

Any help?!!

Luke
  • 41
  • 1
  • 7

1 Answers1

0

Try this:

f = open(file_path, 'r')
x = [int(line) for line in f]
Simon PL
  • 1
  • 1