0

I have a TXT file which contains 100000 lines of short strings from 1-3 digits long. I need a for loop that loops 100000 times, and in the loop I need to read a line then add it to an array and finally move down to the next line. The txt file is called Rand_Numbers and I have opened it as...

C_txt = open("Rand_Numbers", "r")

I don't really know how to do much in python as i'm fairly new to the programming scene. Any help is much appreciated.

Harrison Pugh
  • 113
  • 1
  • 9
  • I think this [question](https://stackoverflow.com/questions/3277503/how-to-read-a-file-line-by-line-into-a-list) is the same as yours. – chluebi Dec 28 '19 at 18:45
  • `with open('ur_file.txt') as f: list_of_ints=[int(e) for e in f]` – dawg Dec 28 '19 at 18:47

1 Answers1

1

welcome to Python. how about

dump_here = []
with open('your_file.txt') as my_file:
    for line in my_file:
        dump_here.append(line)
Axblert
  • 556
  • 4
  • 19