0
class Input:
    def promptMessage(self,name,measure):
        
        self.name = name
    
        
        while True:
            try:
                num = int(input("Please Enter Your {} in {} ".format(name,measure)))
            except ValueError:
                print("Please enter a number")
            else:
                break
        return num
            
class Person:
    def __init__(self):
        input = Input()
        weight = input.promptMessage('weight','Kilo')
        height = input.promptMessage('height','Kilo')
    def __str__(self):
    
        return "Your weight Is {} and your height {}".format(weight,height)
       
class BMI:
    def __init__(self,jack):
        result = jack.hieght
    def __str__(self):
        return result

    
jack = Person()
bmiCal = BMI(jack)    

can someone please explain how I can get the height and weight attributes inside the Bmi object

I have had experience with java but in java I could easily pass one object inside another and use there attributes and even edit them

  • This is a simple typo. Please think about it carefully: where the code says `self.wieght = input.promptMessage('Wieght','Kilo')`, why does it say `self.wieght`, and not just `wieght`? Now, do you see how the same reasoning applies to the `BMI` class? – Karl Knechtel Jun 29 '22 at 03:52
  • As an aside: the words are spelled `height` and `weight`, respectively. – Karl Knechtel Jun 29 '22 at 03:52
  • For future reference: please read [ask] and https://ericlippert.com/2014/03/05/how-to-debug-small-programs/, and try to find simple problems before posting. This starts with *reading* and [*trying to understand*](https://meta.stackoverflow.com/questions/261592) exception messages. If you still need to ask, make sure to **ask a question** - don't just show us some code and an error message. Use your words, in full English sentences, to explain exactly what you need help with. – Karl Knechtel Jun 29 '22 at 03:56

0 Answers0