-4

What it's wrong with this code?

from math import*

def euclidean_distance(x,y):

    return sqrt(sum(pow(a-b,2) for a, b in zip(x, y)))

print euclidean_distance([0,3,4,5],[7,6,3,-1])

This is a Python code that I'm running under Windows.

I don't see anything wrong, but, despite of that, the Python interpreter produce a syntax error in the print statement.

ionecum
  • 101
  • 10

1 Answers1

3

I couldnt comment, so I am posting as answer. You need to put () for print. Try

from math import*

def euclidean_distance(x,y):

    return sqrt(sum(pow(a-b,2) for a, b in zip(x, y)))
#added parentheses here
print(euclidean_distance([0,3,4,5],[7,6,3,-1]))
Shreyas Prakash
  • 604
  • 4
  • 11
  • 2
    Since he was getting error, I assumed he was using 3 – Shreyas Prakash Sep 05 '21 at 03:21
  • Yes, this was exactly the problem. Online tutorials use old versions of languages, then languages change and they don't update. Thank you to all, you saved me from a mental illness! – ionecum Sep 06 '21 at 03:52