Sarai the Geek
April 22nd, 2009, 04:49 AM
Okay, as I said in the title, it is so insanely basic I'm embarrassed that I can't figure it out. I've run umpteenth google searches and have found nothing.
I can't get python to divide. At all. I'm doing some number crunching for a research paper and I need to run the same basic equation over and over again with a single variable, soI figured that writing a quick program could speed things up, but so far I've just ended up pulling a lot of my hair out.
Here's my code:
import math
indiv = raw_input("# of Individuals: ")
dens = indiv/3
print dens
But every time I try to run it it lets me define indiv then spits this out:
File "popecodens.py", line 4, in <module>
dens = spec/3.0
TypeError: unsupported operand type(s) for /: 'str' and 'float'
Gah! What am I missing?
I can't get python to divide. At all. I'm doing some number crunching for a research paper and I need to run the same basic equation over and over again with a single variable, soI figured that writing a quick program could speed things up, but so far I've just ended up pulling a lot of my hair out.
Here's my code:
import math
indiv = raw_input("# of Individuals: ")
dens = indiv/3
print dens
But every time I try to run it it lets me define indiv then spits this out:
File "popecodens.py", line 4, in <module>
dens = spec/3.0
TypeError: unsupported operand type(s) for /: 'str' and 'float'
Gah! What am I missing?