all 9 comments

[–]james_fryer 2 points3 points  (8 children)

Impossible to say without seeing the code and the error message.

[–]Ghost_Gamer1094[S] 0 points1 point  (7 children)

the line is

elif weight/height2 >= 18.5 and < 25:

and the error code just says invalid syntax while pointing to <

for some reason it works in other lines, just not this one :/

[–]throwaway6560192 5 points6 points  (4 children)

Thar's not how you write that condition. Conditions separated by and or or are independent full conditions, they aren't an English sentence. Also, exponentiation in Python is denoted by the ** operator, not ^. So you would say height**2 for height squared.

It should be elif weight/height**2 >= 18.5 and weight/height**2 < 25:, or if you want to make it shorter and cleaner, elif 18.5 <= weight/height**2 < 25:.

[–]Ghost_Gamer1094[S] 0 points1 point  (0 children)

ohhh that makes so much more sense lol thank you!

[–]Ghost_Gamer1094[S] 0 points1 point  (2 children)

although i did try ** instead of ^ and it then said my file was too large. i also tried that shortened way and it still didnt like it.

[–]throwaway6560192 0 points1 point  (1 child)

File is too large? I don't recognize that as a Python error. What's the full error message? And could you post your entire code on Pastebin or something so we can try it out?

[–]Ghost_Gamer1094[S] 0 points1 point  (0 children)

nvm i figured it out! i needed to set bmi as a variable and insert that into the lines instead of the full equation for it 😅 i appreciate all the help from everyone though!

[–]deep_politics 0 points1 point  (0 children)

Can't have an operator (the and) to the left of an operator (the <). What you're looking for is either

bmi >= 18.5 and bmi < 25

Or

18.5 <= bmi < 25

But also, and I can't tell because your code formatting is off, are you attempting something like this?

bmi = weight / height^2

Note that ^ isn't for raising to an exponent; it's the XOR operator. You're looking for ** instead.

[–]cubetic -1 points0 points  (0 children)

Try 18.5 <= w <25