Mar-20-2018, 06:59 PM
i been trying for hours, no luck
the function ask the user what name he want to delete from the text file
the function ask the user what name he want to delete from the text file
1 2 3 4 5 6 7 8 9 10 |
def Delete_con(): with open ( 'phonebook1.txt' , 'r+' ) as f: t = f.read() to_delete = input ( 'What should we delete? : ' ).strip() f.seek( 0 ) for line in t.split( '\n' ): if line ! = to_delete: f.write(line) f.truncate() return Menu() |