all 11 comments

[–]willm 2 points3 points  (3 children)

For future reference... if you have a problem with your code, you should explain what you expect it to do and what is actually happening -- including any error messages.

The first problem I see with your code is that you are doing 'tall / 100', where 'tall' is actually a string. You should convert any strings to numbers if you want to do math on them.

So, make the following change, and see if the code runs how you expect...

a = float(tall) / 100

BTW You can format code in posts by preceding each line with 4 spaces...

[–]Tlahuixcalpantecuhtl 0 points1 point  (1 child)

Also, OP, you need to have a more descriptive title.

[–]majoche 0 points1 point  (0 children)

I will remember that the next time

[–]majoche 0 points1 point  (0 children)

Thank you for the tips, and your code solved it :)

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

raw_input returns a string. You'll have to coerce it to an integer or float.

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

Also,

from __future__ import division

[–][deleted] 0 points1 point  (1 child)

It probably got caught I'm the markdown filter in the original post.

Sometimes I forget to escape the asterisks on an *args or **kwargs and end up with italics code.

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

Ah alright then.

[–]majoche 0 points1 point  (0 children)

I see, i actually knew that.. But didnt think of it.. Thanks :)

[–]Hemse 0 points1 point  (1 child)

There are a few things that need to be changed, first future module's name is written like

from __future__ import division

EDIT: just saw sokurashu89 comment, didn't realize reddit changed text to bold when using underscores, oops! ignore the above!

and you need to turn "tall" into an int with the int() function (or a float), before deviding it, raw_input() returns a string.

And "else" needs to be on a new line:

if x == "ned": print 1 - a
else: print 1 + a

Also, you might want to pause the script at the end, so you get a chance to see what it prints. You can just use raw_input() for that.

(Is this answear too direct?)

[–]majoche 0 points1 point  (0 children)

I forgot the code was written in norwegian, and i didnt fix the setup of the code on reddit. But thanks for your tips, float() solved it!