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


Messages In This Thread
Module 2 Required Coding Activity - by silverdog - Nov-27-2018, 04:41 PM
RE: Module 2 Required Coding Activity - by nilamo - Nov-27-2018, 06:13 PM
RE: Module 2 Required Coding Activity - by nilamo - Nov-27-2018, 07:34 PM

Forum Jump:

User Panel Messages

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