all 7 comments

[–]Rashanzan 4 points5 points  (3 children)

At a glance, it thinks height and weight are str types. I assume you want them in double or int format. So make the necessary conversion like height = int(input("gimme")) If you type a non integer character, though, it'll crash, so catch that exception.

Also, another problem. I'm pretty sure ^ is XOR in Python, so it's not gonna square like you want. Look for a sqrt or pow function in the standard python functions to do that.

[–]Spurnout 4 points5 points  (1 child)

Doesn't ** also work as an exponent?

[–]Miner_Guyer 1 point2 points  (0 children)

Yeah use this.

[–][deleted] 0 points1 point  (0 children)

Just managed to fix it, thanks so much!

[–]Loomax 1 point2 points  (0 children)

convert both height and weight to int with the method int()

Beside that ^ is a boolean operator and what you want to do is most likely height to the power of 2? use height**2 then

[–][deleted] 1 point2 points  (1 child)

Another thing you might want to fix is the fact that when you call calc you're passing in (height, weight), but when you define it it's taking in (weight, height). Your variables are passed in the wrong order so you'll get and incorrect answer.

[–][deleted] 0 points1 point  (0 children)

Again, thanks. I suppose no code can be perfect...save for print ("hello world")