My txt file:
name, city, a, 5
name1, city1, b, 18
name2, city2, a, 4
def main():
try:
with open("actions.txt", "r") as infile:
lines = infile.readlines()
a = 20
aa = 0
newset = set()
for line in lines:
line_1 = line.strip().split(", ")
if a != 0:
if line_1[2] == "a" and int(line_1[3]) <= a and aa <= 2:
aa += 1
a = a - int(line_1[3])
newset.add(f"a's: {line_1[0]} \t {line_1[3]}\n")
print(newset)
except FileNotFoundError:
exit(f"File not Found")
The program needs to read the txt file and make some operations only with objects in lines with name "a". I thought that i did everything correct but pycharm outputs nothing