It may also be good to note though that you don’t ever call estimated_time_rounded. If you were to call it, you’d actually receive an UnboundLocaleError due to rounded_time not being defined.
I have tried putting the return below to the assigned, still it shows the same output.
I expect the out put to be “It will take approximately 6 hours” as it should round the value!!
If I call that function it gives name error. that is “NameError: name ‘estimated_time’ is not defined”
You might have to include the changes you made to make it clear to folks what you’ve done. Have a look at the following if you’re adding code to the forums- How do I format code in my posts?
def destination_setup(origin, destination, estimated_time, mode_of_transport="Car"):
print("Your trip starts off in " +origin)
print("And you are traveling to " +destination)
print("You will be traveling by "+ mode_of_transport)
print("It will take approximately " + str(estimated_time) + " hours")
def estimated_time_rounded(estimated_time):
rounded_time = round(estimated_time)
return rounded_time
trip_planner_welcome("Abdul !")
destination_setup("New Delhi", "Hariyana", 5.65)
The output is as below:
56789101112131415161718
Write your code below:
def trip_planner_welcome(name):
print("Welcome to tripplanner v1.0 " + name)
def destination_setup(origin, destination, estimated_time, mode_of_transport=“Car”):
print("Your trip starts off in " +origin)
print("And you are traveling to " +destination)
print("You will be traveling by "+ mode_of_transport)
print(“It will take approximately " + str(estimated_time) + " hours”)
Output-only Terminal
Output:
Welcome to tripplanner v1.0 Abdul !
Your trip starts off in New Delhi
And you are traveling to Hariyana
You will be traveling by Car
It will take approximately 5.65 hours
Following your lesson link, I think they’re asking for simpler. When I did this I ran the rounding function on a time and assigned it to a variable, then used that variable to call the destination_setup function.
it does work if you leave your functions as I quoted earlier and do a function call inside the print statement
print("It will take approximately " + str(estimated_time_rounded(estimated_time)) + " hours")