jeudi 23 novembre 2017

Check if python method returns a value

Im writing a method to see if a method on an object returns a value and then append a value based on if it does or not to a list. I keep getting a [] whenever i write this. Looking for some help. Thanks

def get_uncommon_colors(self):
    uncommon_colors_list=[]
    for newCard in self.cardlist:
        if newCard.get_rarity=="Uncommon":
            uncommon_colors_list.append(newCard.get_colors())
        else:
            continue
    return(uncommon_colors_list)

Test data:

{
    "name" : "Sen Triplets",
    "manaCost" : "{2}{W}{U}{B}",
    "cmc" : 5,
    "colors" : ["White", "Blue", "Black"],
"type" : "Legendary Artifact Creature — Human Wizard",
"supertypes" : ["Legendary"],
"types" : ["Artifact", "Creature"],
"subtypes" : ["Human", "Wizard"],

"rarity" : "Uncommon",
}

Aucun commentaire:

Enregistrer un commentaire