Python Forum
Module 2 Required Coding Activity
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Module 2 Required Coding Activity
#1
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")    
Reply
#2
(Nov-27-2018, 04:41 PM)silverdog Wrote: gived me error
What's the error?
Reply
#3
in the Module 2 Required Code Submission, gaved me error when submitted and sais I have used 1 of 2 attempts
Reply
#4
(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.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020