Jonathan Gonzalez4,823 Points
Do the instances of D6 have names?
From what I understand, by running the for loop in the Hand class, we created 5 instances of the D6 class and added them to our list(yh), which is an instance of the Hand class. Do those instances of the D6 class have names and if so, how are they generated?
Megan AmendolaTreehouse Teacher
Class instances only have names if you set them equal to a variable. For instance:
class Dog: pass
If I have a class called Dog and I create a bunch of instances using a for loop:
for i in range(10): Dog()
These instances don't have a specific name, they are just instances. I can, however, set instances equal to a variable like this:
my_dog = Dog() your_dog = Dog() # etc...
Then these instances have variables names to go with them.