Python: input, raw_input, and inadvertently treating integers as strings
|
|
This is a "newbie" mistake, but these little details do tend to get in the way, which is why I'm posting my wee Python tutorial. If you know Python or programming, even reasonably well, this will probably seem way too simple to you. Just giving you a "heads up" so you don't waste your time. I encountered a lesson that teaches storing conditionals using booleans. The code was presented like this:..
|
|
young = age < 45
slim = bmi < 22.0
if young and slim:
risk = "low"
elif young and not slim:
risk = "medium"
elif not young and slim:
risk = "medium"
elif not young and not slim:
risk = "high"
Of course, you can't really run this. If you try, you get this: Full Story |
This topic does not have any threads posted yet!
You cannot post until you login.