my textfile has some numbers below
5
13
2
63
How can I store those numbers into an array? Thanks!!!
my textfile has some numbers below
5
13
2
63
How can I store those numbers into an array? Thanks!!!
This is one way to achieve that:
with open('filename') as file:
lines = [i.strip() for i in file]
If you want your list to contain the numbers (int) instead of strings the following code will achieve this:
with open('seq.txt') as f:
numbers = [int(i) for i in f]
Thanks to Ninja Puppy♦ to improve the code.