I need help on the define function in returning result | Coursera Community

I need help on the define function in returning result

Badge +1

i have been stuck on week two test in google python automation 

i keep on having indentation error.

# 1) Complete the function to return the result of the conversion

def convert_distance(miles):

    km = miles * 1.6  # approximately 1.6 km in 1 mile


    return km


    my_trip_miles = 55


# 2) Convert my_trip_miles to kilometers by calling the function above

my_trip_km = convert_distance(my_trip_miles)


# 3) Fill in the blank to print the result of the conversion

print("The distance in kilometers is " + str(my_trip_km) )


# 4) Calculate the round-trip in kilometers by doubling the result,

#    and fill in the blank to print the result

print("The round-trip in kilometers is " + str(2*my_trip_km))

Please i need help and guidance on what i have been doing wrong.

2 replies

Userlevel 7
Badge +8

Hi @Mfonafia . you can post this also in the discussion forum of the course their you will find more learners and mentors they can help you faster then the community this a help article how to use the discussion forum : Get help with course content in the discussion forums

also maybe you will find some replies here from other learners if they can help you .

Delete any white characters (spaces, tabs, etc.) directly before:

my_trip_miles = 55

Currently it is indented, as if it was a part of the function definition - which most obviously should not be true.

Also, is print() statement necessary inside the function? (was it already predefined there?) - it may cause some trouble during the next step.