I input: weight = input() height = input() x = (weight/height/height) if(x < 18.5): print("Underweight") if(x >= 18.5 and x < 25): print("Normal") if(x >= 25 and x < 30): print("Overweight") if(x > 30): print("Obesity") It outputs: Trace back (most recent call last) File “/usercode/file0.py”,in <module> x = (weight/height/height) TypeError: unsupported operand type(s) for ** or pow() : ‘str’ and ‘int’
6/8/2022 2:52:11 AM
Mohamed Hytham25 Answers
New AnswerIt's because something is wrong. If you need help on finding out what, pls edit your question with: 1. The error 2. A tag with the language
Jibran Khan sᴜᴊᴀɴ.ᴇ.s. Pls avoid answering with finished code. Remember this is a learning app. We have to help others to know how to solve problems - if we solve for them, there's no learning. Prefer giving hints the OP can follow and find the solution.
Nícolas Nascimento Good. Just check the lesson or docs for 'input' function and review the arguments you passed to it in your code.
😳 you surprise me. Have you taken a Python course? Variables go first, then conditional branches. How did you write this code?
Here is the correct code for it weight = int(input()); height = float(input()); x = weight/float(height*height); if x < 18.5: print('Underweight') if x>=18.5 and x<25: print("Normal") if x >= 25 and x < 30: print('Overweight') if x >= 30: print('Obesity')
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message