Python:A Methodical Approach


#1

Hello friends ,I am have question for you

https://www.codecademy.com/courses/python-intermediate-en-WL8e4/1/3?curriculum_id=4f89dab3d788890003000096#

Although my code is correct,I get following output

Charlie
15
None
None

What is the meaning of these "None"?This seems to be present at the end of all challenges output.Why is this so?Where is the commands in my code which prints them out?Follwing is my code

class Animal(object):
    """Makes cute animals."""
    is_alive = True
    def __init__(self, name, age):
        self.name = name
        self.age = age
    # Add your method here!
    def description(self):
        print self.name
        print self.age
        
hippo=Animal("Charlie",15)
print hippo.description()
.

#2

function and methods return None by default. Your description method doesn't return anything, but you have print in front of method call, causing None to be printed

i suspect the last none to be from codecademy, but repl doesn't work at the moment, try running your code there to see how it looks


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.