Python OOP - object has no attribute
- by user1744269
I am attempting to learn how to program. I really do want to learn how to program; I love the building and design aspect of it. However, in Java and Python, I have tried and failed with programs as they pertain to objects, classes, methods.. I am trying to develop some code for a program, but im stumped. I know this is a simple error. However I am lost! I am hoping someone can guide me to a working program, but also help me learn (criticism is not only expected, but APPRECIATED).
class Converter:
def cTOf(self, numFrom):
numFrom = self.numFrom
numTo = (self.numFrom * (9/5)) + 32
print (str(numTo) + ' degrees Farenheit')
return numTo
def fTOc(self, numFrom):
numFrom = self.numFrom
numTo = ((numFrom - 32) * (5/9))
return numTo
convert = Converter()
numFrom = (float(input('Enter a number to convert.. ')))
unitFrom = input('What unit would you like to convert from.. ')
unitTo = input('What unit would you like to convert to.. ')
if unitFrom == ('celcius'):
convert.cTOf(numFrom)
print(numTo)
input('Please hit enter..')
if unitFrom == ('farenheit'):
convert.fTOc(numFrom)
print(numTo)
input('Please hit enter..')