I just started coding nine days ago, and I thought I was getting used to it, but I’m still having fundamental issues. Below is a copy of the code that I wrote, it’s giving me a null error on the distance = hero.distanceTo(item) line. Can anyone explain this to me because I am having a very hard time figuring this out?
The artillery uses coins as a target.
You’ll be the rangefinder for the artillery.
Write the function.
# Find the nearest coin,
item = hero.findNearestItem()
# If there is a coin, return the distance to it.
distance = hero.distanceTo(item)
# Else, return 0 (zero).