Untitled
unknown
python
16 days ago
720 B
4
Indexable
Never
with open("global.txt", "r") as f: filtr = input("Subject-University: ") output_file = input("file name: ") with open(f"{output_file}.txt", "w") as kosai: kosai.write("Serial - Merit - Roll - Name\n") for line in f: lines = line.split() try: serial = int(lines[0]) roll = int(lines[1]) subject = lines[-1] merit = lines[-2] name = line.split(lines[1])[1].split(lines[-2])[0].strip() if subject == filtr: with open(f"{output_file}.txt", "a") as kosai: kosai.write(f"{serial} - {merit} - {roll} - {name}\n") except ValueError: pass
Leave a Comment