19. built in functions


#1



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

Oops, try again. Your function seems to fail on input -10 when it returned 'None' instead of '10'

File "python", line 5
else:
^
IndentationError: unindent does not match any outer indentation level


nothing just some help?


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


I am very aware that a few moderators have been trying to help people. i have trolled through most of them from 20 days ago. i dont understand there explanations or i wouldn't ask for help.


#2

Your else statement is indented too far. Delete the spaces in front of it until it is in line with the if above it.


#3

This should be indented by the same degree as the if header, in order for both block headers to match each other ...

else:

#4

thank you all. didnt know white space mattered that much..... armature hour!!! cheers


#5

In Python, indentation must be exact, in order for the program to run properly. Unlike languages such as Java, JavaScript, and Ruby, that use things like braces to define the opening and closing of a piece of code with a body, we put a colon, and everything indented once from there is a part of it. This colon is called a delimiter.

For more information, you can go here:

http://www.diveintopython.net/getting_to_know_python/indenting_code.html

Enjoy! :snake:


#6

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