The Nile Project

I’m working on the Nile project: https://www.codecademy.com/courses/learn-python-3/projects/function-args-the-nile

I’m at step 8, and I thought my code was correct (and checked it against the YouTube video - and it looks the same):
def calculate_shipping_cost(from_coords, to_coords, shipping_type = ‘Overnight’):
from_lat, from_long = from_coords
to_lat, to_long = to_coords
distance = get_distance(*from_coords, *to_coords)
shipping_rate = SHIPPING_PRICES[shipping_type]
price = distance * shipping_rate
return format_price(price)

And when I run the test script (step 8), I get this error:
Traceback (most recent call last):
File “script.py”, line 14, in
test_function(calculate_shipping_cost)
File “/home/ccuser/workspace/function-args-nile/test.py”, line 3, in test_function
test_shipping(fn)
File “/home/ccuser/workspace/function-args-nile/test.py”, line 21, in test_shipping
print("\u2705 calculate_shipping_cost() passes tests")
UnicodeEncodeError: ‘ascii’ codec can’t encode character ‘\u2705’ in position 0: ordinal not in range(128)

Is this an error in my code? Or is it something else?

Hi @dmarui,

The code that you wrote is not the cause of the problem. Rather, the fault lies in a file named test.py that is part of the project. That file contains several print statements that include a :white_check_mark: character that the print function is unable to process properly.

The good news is that you can correct that file. Click the folder icon in the upper left corner of the editing window. Then you will see a list of files, including test.py. Click the name of that file to open its contents for editing.

In several places, you will find statements that include a check mark, for example.

print("✅ calculate_driver_cost() passes tests")

In all those cases, you should remove that character. After all of them have been removed, save the file, close it, and go back to working with the script.py file.

1 Like

Thanks @appylpye!

It works now.

1 Like

Note that Codecademy is currently (as of May 14, 2019) executing our scripts in Python version 3.5.2 .

The following executed successfully within a Python IDLE 3.7.0 interactive session:

print("✅ calculate_driver_cost() passes tests")

Here’s a copy of the session:

Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 26 2018, 23:26:24) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "copyright", "credits" or "license()" for more information.
>>> print("✅ calculate_driver_cost() passes tests")
✅ calculate_driver_cost() passes tests
>>>
1 Like

I had the same issue today as well. I had to remove the checkbox characters to progress through the lesson.