1.) Before We Begin Passes But Not Right


#1

So my code is as below and it is a simple lesson. However, it did not put up 42 on the screen. I do not know if this is necessary since it asked only to return the value but I was assuming it would come back up on the screen. So I was wondering how I would get that without using arguments like it asked in the instructions. I figure this is important to this lesson so I better get it right before I move on.


def answer():
    return 42.


#2

You need a print statement somewhere. And you need to remove that period after 42 or else it's going to print "42.0".

There's three ways you can print 42.

def answer():
    print(42)

#or
def answer():
    return 42

print answer()

#3

Ah thanks! And yeah the period got in when I pasted my code in somehow xD


#4

Actually neither of those passed... I keep getting the error that you printed 42 instead of returning but I guess you fixed that in your edit


#5

Yeah, I realized that you needed to return something. The 1st option is for when you don't need to return anything haha.


#6

ok thanks! However, it still doesn't print 42 to the screen...

def answer():
    return 42
    print 42

#7

Did you try option #2? and can you link the lesson too?


#8

Yeah I tried all the options. #1 and #2 both give the print instead of return error and #3 passes but puts up none and yeah here is the lesson below

https://codecademy.com/en/courses/python-beginner-P5YtY/0/1?curriculum_id=4f89dab3d788890003000096


#9

haha, it's because they didn't want you to print anything!
For me #1 and #2 does print the number on the screen but it gives the error. #3...doesn't work, I'll change that.


#10

Yeah, I was wondering about that. I said in my first post I wasn't for sure it needed to go up there but anyhow xD I learned a nice bit about this so that is good thanks for the help!


#11

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