'is there any need or use for a class in this case

does this class have any use and how could i make it be incorporated into this code

class Person:
    def __init__(self, race, age, height):
        self.race = race
        self.age = age
        self.height = height


race_var = input("what race are you?: ")
height_var = input("what height are you?: ")
age_var = input("what age are you?: ")
Person.race = race_var
Person.height = height_var
Person.age = age_var

print("You are of the", race_var, "race")
print("You are", height_var, "tall")
print("you are", age_var, "years old")


Solution 1:[1]

You want to create an instance of the class

class Person:
    def __init__(self, race, age, height):
        self.race = race
        self.age = age
        self.height = height

race_var = input("what race are you?: ")
height_var = input("what height are you?: ")
age_var = input("what age are you?: ")

person = Person(race_var, height_var, age_var)

print("You are of the", person.race_var, "race")
print("You are", person.height_var, "tall")
print("you are", person.age_var, "years old")

As for whether it is useful, well, there is some utility in associating those three values. But otherwise the class doesn't do anything a simple dict couldn't do. So, kinda useful.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 tdelaney