Two values are not recognized together in the same key of a dictionary. Error: None

Viewed 43

I need to print the output L'Atalanta è chiamata if in subject i write subject = "Atalanta".

While, i need to view the output La Cremonese è chiamata if in subject I write subject = "Cremonese".

THE ERROR I get correctly L'Atalanta è chiamata, but for Cremonese I get La Cremonese None, so error NONE.

PROBLEM. The problem is the various dictionary, precisely the apostrophe key. I would like to enter together the values "yes" and "no", but only the first value (yes) is detected, while the second value (no) is not.

MY ATTEMPTS TO SOLUTION. I tried "apostrophe": "yes" or "no", "apostrophe": ["yes", "no"], "apostrophe": {"yes", "no"} and "apostrophe": ("yes" , "no"), but it doesn't work. In fact, if you write backwards ("no", "yes"), then the Atalanta will not be printed correctly, but the Cremonese correctly.

How can I correctly print both L'Atalanta è chiamata and La Cremonese è chiamata depending on the name entered in subject?

P.S: I would like to try to remain a dictionary structure as similar as possible to what I have (if possible)

team = {
        "Atalanta": {"gender" : "female", "unit" : "singular", "apostrophe" : "yes"},
        "Cremonese": {"gender" : "female", "unit" : "singular", "apostrophe" : "no"},
        }

article_words = {    
            "L'" : {
            "gender" : "female",
            "unit" : "singular",
            "apostrophe": "yes",
            },
            
            "La " : {
            "gender" : "female",
            "unit" : "singular",
            "apostrophe": "no",
            },
                                   
        }
#HERE IS PROBLEM
various = {
            "è chiamata" : {
            "gender" : "female",
            "unit" : "singular",
            "apostrophe": "yes" or "no", ### HERE
            },                       
        }

##################


def function():
    
    subject = "Atalanta"

    def article(subject):
        #Change Article for Team (choose IL or L ')
        for key, value in article_words.items():
            if team[subject] == value:
                return key

    def chiamato(subject):
        #Change "è chiamato/a" related to Team
        for key, value in various.items():
            if team[subject] == value:
                return key
                
    article = article(subject)
    chiamato = chiamato(subject)


    phrase = f"{article}{subject} {chiamato}"
    print(phrase)

function()
0 Answers
Related