Python Forum
Module 2 Required Coding Activity - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: Module 2 Required Coding Activity (/thread-14391.html)



Module 2 Required Coding Activity - silverdog - Nov-27-2018

Hi,
My code seems running fine on jupyter notebook,
but when pasted into the Module 2 Required Code Submission gived me error ... Huh
Any hint ? Smile

# [] create list-o-matic
# [] copy and paste in edX assignment page

zoo = ['cat', 'goat', 'cat']

def list_o_matic(animal):
    if animal == "":
        animal = zoo.pop()
        print(animal + " popped from list")
    elif animal in zoo:
        zoo.remove(animal)
        print("1 instance of " + animal + " removed from list")
    else:
        zoo.append(animal)
        print("1 instance of " + animal + " appended from list")

while True:
    if zoo == "":
        break
    else:
        animal_name = input("enter the name of an animal: ")
        if animal_name.lower().startswith("q"):
            break
        else:
            list_o_matic(animal_name)
            print(zoo)

print("goodbye")    



RE: Module 2 Required Coding Activity - nilamo - Nov-27-2018

(Nov-27-2018, 04:41 PM)silverdog Wrote: gived me error
What's the error?


RE: Module 2 Required Coding Activity - silverdog - Nov-27-2018

in the Module 2 Required Code Submission, gaved me error when submitted and sais I have used 1 of 2 attempts


RE: Module 2 Required Coding Activity - nilamo - Nov-27-2018

(Nov-27-2018, 07:11 PM)silverdog Wrote: gaved me error when submitted
Ok but what was the error?

The only thing that sticks out to me, is input(). If whatever you're submitting to is using python2, that would probably not work right. But without knowing what errors you're getting, I'm just guessing.