hargikana
hargikana

Reputation: 1

Reading from file to add to list

I need to get from list(file) who is coming to party and who is not.

File looks like this:

(+) John
(?) Jake
(+) Billie

How to read that person with + is coming ?

Upvotes: 0

Views: 42

Answers (1)

부건혁
부건혁

Reputation: 93

file = open("your_file", "r")
c = []
for line in file:
    if line[1] == '+':
        c.append(line[4:].strip())
print(c)

Upvotes: 1

Related Questions