Quick coding help? Thank you

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!

This is a homework assignment that is already being discussed in another topic. Take a gander at the discussion and see it you don’t find some direction there.

It was also recommended that the member go through the Python track on the main site so you get up to speed. The above is not a difficult task, and if you cannot complete it on your own, I’m sorry to say you are not going to have a good semester. Things are only going to get harder. Better grab your bootstraps and pull up hard. You’ve got some catching up to do.

I had my code checked over and had conflicting commands. Thank you for the help, I noticed my mistake when I took a glance at the thread.

1 Like