dieren

mail@pastecode.io avatar
unknown
plain_text
8 months ago
1.5 kB
1
Indexable
Never
class animal:
    def __init__(self, name, soort, geslacht, geluid):
        self.name = name
        self.soort = soort
        self.geslacht = geslacht
        self.geluid = geluid

    def animal_info(self, Name):
        for i in range(len(animals)):
            if animals[i]["animal"]["name"].upper() == Name.upper:
                self.name = animals[i]["animal"]["name"]
                self.soort = animals[i]["animal"]["soort"]
                self.geslacht = animals[i]["animal"]["geslacht"]
                print(f"the {self.name} is a {self.geslacht} from the {self.soort} family")
            else:
                pass



    def animal_sound(self, Name):
        for i in range(len(animals)):
            if animals[i]["animal"]["name"].upper() == Name.upper():
                self.geluid = animals[i]["animal"]["geluid"]
                print(f"the sound that the {animals[i]["animal"]["name"]} makes is {self.geluid}")
            else:
                pass



for i in range(len(animals)):

    iNAME = animals[i]["animal"]["name"]
    iSOORT = animals[i]["animal"]["soort"]
    iGESLACHT = animals[i]["animal"]["geslacht"]
    iGELUID = animals[i]["animal"]["geluid"]

    iANIMAL = animal(iNAME, iSOORT, iGESLACHT, iGELUID)

    animal_choice = input("what animal would you like to know about? ")
    iANIMAL.animal_info(Name=animal_choice)
    iANIMAL.animal_sound(Name=animal_choice)
    print("-----" * 8)
Leave a Comment