saving and deleting fileI/O
Two part question.
First, how can i change this(i've tried using 'for' but i cant figure it
out) so that it saves like; 'key value' instead of '{key: value}'.
with open("phonebook.txt", "w") as x:
json.dump(a, x)
Second, how do you delete from a file by using the users input. I cannot
see a way of changing this to delete from file instead of the dict 'a';
name = input("enter name of contact you want to delete: ")
if name in a:
del a[name]
No comments:
Post a Comment