Create file phonebook.dat that stores the details in
following format:
Name Phone
Jivin 86666000
Kriti 1010101
Obtain the details from the user.
Answer:
f=open(
"phonebook.dat"
,
'w'
)
f.write(
"Name Phone\n"
)
while True:
name=input(
"Enter name:"
)
phone=input(
"Enter phone number: "
)
f.write(name+
" "
+phone+
"\n"
)
more=input(
"Want to enter more? Enter Y if yes: "
)
if more.upper() !=
'Y'
:
break
f.close()
File phonebook.dat: