What did I do wrong


#1



https://www.codecademy.com/en/courses/python-beginner-en-zFPOx/0/5?curriculum_id=4f89dab3d788890003000096

Oops, try again. It looks like your printed time is not in the proper format: hh:mm:ss

It to let me pass


Replace this line with your code. 
from datetime import datetime
now = datetime.now()

print '%s:/%s:/%s' % (now.hour, now.minute, now.second)


#2

You seem to have needless slashes. Please remove. See below.

print '%s:%s:%s' % (now.hour, now.minute, now.second)

Hope this helps! :slight_smile:


#3

Thanks a lot : srry about replying late::slight_smile:


#4

It's fine.

Have fun coding! :slight_smile:


#5

What is wrong? I am in the Grand Finale.
print'%s/%s/%s %s:%s:%s'(now.month, now.day, now.year, now.hour, now.minute, now.second)


#6

How you do that is:

print '%s:%s:%s' % (now.hour, now.minute, now.second)

I assume this is your issue and you got the others right.


#7

I have a question: https://www.codecademy.com/en/courses/python-beginner-c7VZg/4/3?curriculum_id=4f89dab3d788890003000096#

Requirement:
First, def a function called distance_from_zero, with one argument (choose any argument name you like).
If the type of the argument is either int or float, the function should return the absolute value of the function input.
Otherwise, the function should return "Nope"

My code is as follow, could you help me figure out the problem, thank u!

def distance_from_zero(thing):
absolute=abs(thing)
if type(thing) = int or float
return absolute

else:
    return "Nope"

#8

Instead of "thing" as an argument to the "distance_from_zero" function, use "num". With this, you should use the "num" argument until the absolute return, ie "return abs (num)".

Then create the "if" statement, type with the argument ("type (num)"), which is equal to, "int or float" ("type (num) == int or type (num) == float ").

I hope you understood.


#9

thank you, I did as follow, but it didn't work.

def distance_from_zero(num):
absolute=abs(num)
if type(num) == int or type(num) == float
return abs(num)

else:
    return "Nope"

the error warning:
Oops, try again. It looks like you have a NameError. Maybe you forgot to create a function called distance_from_zero? Check the error message for more info! - global name 'distance_from_zero' is not defined


#10

You changed the code order haha :smile:
It's all right just need to exchange one line of code for another!
Assim:

def distance_from_zero(num):
    
    if type(num) == int or type(num) == float:
        return abs(num)   
    else:
        return "Nope"


print distance_from_zero(10)
print distance_from_zero(10.0)
print distance_from_zero(10.0)

#11

print '%s/%s/%s %s:%s:%s' % (now.month, now.day, now.year, now.hour, now.minute, now.second)