From the course: Getting Started with Python Object Oriented Programming: A Hands-On Approach

Unlock the full course today

Join today to access over 24,900 courses taught by industry experts.

Solution: Creating objects from a user-defined class

Solution: Creating objects from a user-defined class

(upbeat music) - [Instructor] Here's a solution to the challenge for this chapter. So we're going to create a new card, card three, and it's going to be an instance of card that's with the capital C, that's the class name. And we're going to pass in, let's say the jack of clubs maybe. And then card four is going to be equal to another instance of card. And obviously these can be whatever you want. Three, let's say, of diamonds. Now I'm going to be lazy here and use alt shift down arrow to duplicate these print statements. And I'm going to print card three and four just to make sure they're coming out as I expected. And you can see down in the terminal we have our original two cards and we have the new cards, which may well be different in your case. But as long as you were able to create these instances, then you have completed this challenge successfully.

Contents