In: Computer Science
This task is solved in Python 3.
Develop a program that lets the user add new people to the file phone.txt
Add name and number, end with <enter>
Name and number: Robin 94567402
Name and number: Jessica 99468283
Name and number:
>>>
| 
 Phone.txt  | 
 Expanded to ------>  | 
 Phone.txt  | 
| 
 Mary 98654321 June 99776655 Chris 99112233 Viv 98554455 John 99776612 Joe 97888776 Rick 99455443 Susan 98122134 Jill 99655732 Bob 98787896  | 
 Mary 98654321 June 99776655 Chris 99112233 Viv 98554455 John 99776612 Joe 97888776 Rick 99455443 Susan 98122134 Jill 99655732 Bob 98787896 Robin 94567402 Jessica 99468283  | 
CODE:-
temp = input("Name and number: ") # TAKING THE USER INPUT
file = open("Phone.txt","a")  # selecting the append mode
while temp:  # THEN iterating until the user has entered something 
    value = list(map(str,temp.split())) # then splitting the input and storing it into list 
    file.write(value[0]+"\n")  # then appending it into the file 
    file.write(value[1]+"\n") # both name and number
    temp = input("Name and number: ") #  again taking the input
file.close()  # finally closing the file 

FILE BEFORE:-

FILE AFTER:-

FOR ANY OTHER QUERY PLEASE COMMENT