Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to assign a variable to a class in python

class Shark:
    animal_type = "fish"
    location = "ocean"
    followers = 5

new_shark = Shark()
print(new_shark.animal_type)
print(new_shark.location)
print(new_shark.followers)
 
PREVIOUS NEXT
Tagged: #assign #variable #class #python
ADD COMMENT
Topic
Name
2+2 =