Module 19/19 - Syntax Error


#1

n = raw_input("Number: ")

def distance_from_zero (n):
if type(n) == int or type(n) == float:
return abs(n)
else:
return ‘nope’

this is my code I have and when I run it the error message says I have a syntax error by “else” and I dont know what is wrong… please help lol


#2

You can figure that out yourself if you start with something very simple you know to be correct and slowly add parts back to it

And, take some care that others can get an exact copy of your code, otherwise the purpose of showing the code is defeated (do you due diligence before asking)


#3

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