Professional Documents
Culture Documents
File Handlingg
File Handlingg
new=""
while True:
x = f1.readline()
if len(x)<=0:
break
y = x.split()
for i in y:
if i[0] in "AEIOUaeiou":
new+="\n"
f2.write(new)
f1.close()
f2.close()
2. Write a menu driven program to add and display data
from a text file. The text file contains Student details (Roll
no, name and marks).
while True:
f1=open(file, "r+")
print("""Choose an option:
1. Add data
2. Read contents""")
if x == "1":
student = []
ch = "y"
print()
student.append(str(rno)+",")
name = name.upper()
student.append(name+",")
student.append(marks + "\n")
if ch == 'y' or ch =="Y":
continue
else:
f1.writelines(student)
if x =="2":
while True:
y = f1.readline()
if len(y)<=0:
break
if z =="n" or z=="N":
break