Python3 json access input data

"python Learning: from beginner to practice" I modeled on an example in the book. Look for the user name, find it, show it, and write to the file if you can"t find it. Now use json to store, only one name can work properly. I think json didn"t parse correctly, and I couldn"t find the answer after looking for it on the Internet. I hope you can tell me how to modify the code.

import  json
def save_name():
    print("")
    name = input("\n :")
    with open("name.json","a") as file:
        json.dump(name,file)
    print(""+str(name))
    return name

def find_name(fn):
    try:
        file = open("name.json","r")
    except FileNotFoundError:
       return save_name()
    else:
        name = json.load(file)
        for i in name:
            if fn == i:
                return fn
            else:
              return save_name()
def hello_name():
    name = input("\n :")
    print(""+str(find_name(name)))
    
hello_name()
Mar.18,2021

first learn the format of json. You can't write open ('name.json','a') one by one in' a 'mode. The way you append it is equal to a json, per line that does not conform to the json format. Of course, you parse the error

.
import  json
def save_name(name):
    -sharpprint("")
    -sharpname = input("\n :") 
    with open('name.json','w') as file:
        json.dump(name,file)
    print(""+str(name[-1]))
    return name[-1]

def find_name(fn):
    try:
        file = open('name.json','r')
    except FileNotFoundError:
       return save_name([fn])
    else:
        name = json.load(file)
        file.close()
        """for i in name:
            if fn == i:
                return fn
            else:  
              return save_name()"""
        if fn in name:
            return fn
        else:
            name.append(fn)
            return save_name(name)

def hello_name():
    name = input("\n :")
    print(""+str(find_name(name)))
    
hello_name()
Menu