Untitled
unknown
python
a year ago
720 B
13
Indexable
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
Editor is loading...
Leave a Comment