Ask coding questions

← Back to all posts
Bits of help might be needed
LukeShomper (49)

I really don't understand how file reading works like,
r = read? I want to know how to read 1 line of a file I'm assuming it's somthing like FileName[0] but it's not.
I need help reading 1 line of a file
Can someone send me an example please :D

mwilki7 (1078)
# open file
with open('your_file_name') as file:
    for line in file:
        # do stuff here
LukeShomper (49)

@mwilki7 ok well thats step 1 it prints ALL the lines like



I need that to go into a list so the list would contain D, C, H,

LukeShomper (49)

Or well the way i made it print all the lines I need it to go into a list

LukeShomper (49)

Like getting 1 line from a list would also work