how_many_legs should take a string which is the name of an animal and return a number representing how many legs the animal has.It needs to recognise at least the following animals:human,chicken,horse,dog,spider,centipede.If it is given an animal it

来源:学生作业帮助网 编辑:作业帮 时间:2024/07/27 00:47:54
how_many_legs should take a string which is the name of an animal and return a number representing how many legs the animal has.It needs to recognise at least the following animals:human,chicken,horse,dog,spider,centipede.If it is given an animal it
xTj@6q!Wu% fԙQL}@骋ew s*B<ؤ-54sܙQ=)ESLKj!sbV0` +􈊗IAm4Y@65 J["1wnA"dW5S,sc}tR]gND T"Efq)3A ŽxCЀT-#kT&ţJC=W$ׄ=/Ϸerqxfm)f%S'ݳSYrwuuپqXЩ [-_>~[}Fz2zG&񉜚c? o3]lXQ̣ `V ObGˮwPF4 au>lH?q'߼=/0gp=[d 6^o\Nٛ;

how_many_legs should take a string which is the name of an animal and return a number representing how many legs the animal has.It needs to recognise at least the following animals:human,chicken,horse,dog,spider,centipede.If it is given an animal it
how_many_legs should take a string which is the name of an animal and return a number representing how many legs the animal has.It needs to recognise at least the following animals:human,chicken,horse,dog,spider,centipede.If it is given an animal it does not recognise,it should print an error message and then return 0.
自己做的:
def how_many_legs(name):
if name == "horse" or "dog":
return "this animal have 4 legs"
if name == "chicken" or "human":
return "this animal have 2 legs"
if name == "spider":
return "this animal have 8 legs"
if name == "centipede":
return "this animal have 30 or 34 legs"
else:
return "error,0"
它就只会打"this animal have 4 legs",求更正,

how_many_legs should take a string which is the name of an animal and return a number representing how many legs the animal has.It needs to recognise at least the following animals:human,chicken,horse,dog,spider,centipede.If it is given an animal it
def how_many_legs(name):
    if name == "horse" or name =="dog":
        return "this animal have 4 legs"
    if name == "chicken" or name =="human":
        return "this animal have 2 legs"
    if name == "spider":
        return "this animal have 8 legs"
    if name == "centipede":
        return "this animal have 30 or 34 legs"
    else:
        return "error,0"