Show me the way (19. Review: Built-In Functions)


It's not necessary for the lesson but can someone show me how you would modify this code so that it takes user input and puts that in for 'a'. Like so instead of typing in 'distance_from_zero(whatever number)', the program would just ask you for a number and put that in the parameters. Thank you in advance

def distance_from_zero(a):
    if type(a) == float or type(a) == int:
        return abs(a)
        return "Nope"
Replace this line with your code.


So the program asks you the number, right? Then my code would probably be

x = raw_input ("Insert your preferred number here: ")

distance_from_zero (x)


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