Basically, I need to check the type of data of which a variable is storing before replacing the data stored in the variable with the new data. For example, how to check if the variable is storing a string data or an integer data?
Source Code:
class Toy:
#Toy Class Constructor
def __init__(self):
Name = "Train Engine";
ID = "TE11";
Price = 0.99;
Minimum_Age = 4;
#Return Name
def Return_Name(self):
print(Name)
return Name
#Set Name
def Set_Name(self, Variable):
#This is where I would need to check the type of data that the variable 'Variable' is currently storing.
Name = Variable
#Return ID
def Return_ID(self):
print(ID)
return ID
#Set ID
def Set_ID(self, Variable):
#This is where I would need to check the type of data that the variable 'Variable' is currently storing.
ID = Variable
#Return Price
def Return_Price(self):
print(Price)
return Price
#Set Price
def Set_Price(self, Variable):
#This is where I would need to check the type of data that the variable 'Variable' is currently storing.
Price = Variable
#Return Minimum_Age
def print_Minimum_Age(self):
print(Minimum_Age)
return Minimum_Age
#Set Minimum_Age
def Set_Minimum_Age(self, Variable):
#This is where I would need to check the type of data that the variable 'Variable' is currently storing.
Minimum_Age = Variable
So basically, how should I, or are there any conventional way to check the type of data that the variable is storing?