+ 1

Can you have a class inside a class?

For example: class Dog: def __init__(self, legs, teeth, Fur): self.legs = legs self.teeth = teeth class Fur: def __init__(self, color, length): self.color = color self.length = length then create Rusty: Rusty = Dog(4, "dull", Fur("brown", "short")) print(Rusty.Fur.color) I don't actually think that this code will run, but you get the idea...

9th Oct 2018, 12:15 AM
Steven Small
Steven Small - avatar
1 Answer
+ 1
was my syntax close? it does not run.
9th Oct 2018, 2:03 AM
Steven Small
Steven Small - avatar