How do the variable in the .format attribute work?

I wrote the following code and don’t know why it didn’t give me an error because I have to variables named “diameter”:

class Circle:
  pi = 3.14
  def __init__(self, diameter):
    print("New circle with diameter: {diameter}".format(diameter = diameter))

I understand that it is not advisable to have identical names for variables, but why doesn’t it give an error in this instance?

link to exercise:

1 Like

You have one variable named diameter
what you’ve done is essentially this

x = 1
x = x