Hi I made an account because I’m horrible at coding and am taking a class at it.
I made the function
def ddg(poultry):
# Write your code here and edit the return statement below as needed.
pts= 0
points= sum(poultry)
for item in ddg(poultry):
if item == “duck”:
points = 1 + pts
elif item == “goose”:
points = 2 + pts
elif item == “egg”:
points = 0
return points
But it’s always returning 0 points while the end should be
############### Part 1 Tests ###############
print('Testing ddg() for [“goose”, “duck”, “duck”, “duck”]: ’ + str(ddg([“goose”, “duck”, “duck”, “duck”])))
print('Testing ddg() for [“duck”, “egg”, “goose”, “egg”]: ’ + str(ddg([“duck”, “egg”, “goose”, “egg”])))
print('Testing ddg() for [“duck”, “duck”, “egg”, “goose”]: ’ + str(ddg([“duck”, “duck”, “egg”, “goose”])))
# Write your own tests for Part 1 here!
print() # prints a blank line
With
Function Call Return Value
ddg([“goose”, “duck”, “duck”, “duck”]) 5
ddg([“duck”, “egg”, “goose”, “egg”]) 0
ddg([“duck”, “duck”, “egg”, “goose”]) 2
As the answers, but I’m getting 0,0,0 when it should be 5,0,2.
Thank you for the help!