Question on 2D point problem

I have a question on why the below program throws an error:

import math

class Point2D:
    def __init__(self, x, y):
        self.__x = x
        self.__y = y
    def calculate_distance(self, other):
        dx = self.__x - other.x
        dy = self.__y - other.y
        return math.sqrt(dx*dx + dy*dy)
point1 = Point2D(3,4)
point2 = Point2D(9,5)

distance = point1.calculate_distance(point2)



AttributeError Traceback (most recent call last)
16 point2 = Point2D(9,5)
—> 18 distance = point1.calculate_distance(point2)
20 print(distance)

in calculate_distance(self, other)
10 def calculate_distance(self, other):
—> 11 dx = self.__x - other.x
12 dy = self.__y - other.y
13 return math.sqrt(dxdx + dydy)

AttributeError: ‘Point2D’ object has no attribute ‘x’

Hi @sathish.sugavanam1,

Why do you need the double underscore in self.x and self.y? Please attach the mission link as per these guidelines so we know the particular mission you are referring to. Thanks!

This is the mission link:

I wanted those two variables to be PRIVATE. Please clarify if my approach in incorrect or python behaves in this way