Click here to Skip to main content
14,981,856 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I copied the code below from a tutorial on youtube about creating class however the code didn't work from my side.

class customer:
    def __init__(self, name, membership_type):
        self.name = name
        self.membership_type = membership_type

customers = [Customer("caleb", "Gold"),Customer("Brad", "Bronze")]

print(customers[0].name)


When i run the code i get the following error;

<pre>line 7, in <module>
    c = Cusomter("caleb", "Gold")
NameError: name 'Cusomter' is not defined

[Done] exited with code=1 in 0.144 seconds


Please note i'm using Visual Studio Code and Linux operating system.

What I have tried:

I have tried editing spaces and underscores to see if this could be the problem.
Posted
Updated 2-Jun-21 23:00pm
Comments
Richard MacCutchan 3-Jun-21 5:18am
   
Your class name is customer, starting with a lower case letter.

1 solution

Spelling is important in computers: "Cusomter" is not the same as "Customer" ...
   
Comments
CPallini 3-Jun-21 5:16am
   
:-)
5.
Richard MacCutchan 3-Jun-21 5:18am
   
Nor is it the same as "customer".
CPallini 4-Jun-21 4:52am
   
:-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900