Obviously, fc_no_rocks is a string in your case. That bug is on you. Better to check for several cases:
fc_no_rocks is a number
fc_no_rocks is a string indicating a number
fc_no_rocks is neither of the above
You check to make sure that fc_no_rocks isn't None, but it could be anything. So it's better to check more exclusively at first, and then let your else case be the catch-all, i.e. neither/none of the above.
In one big mess of a ternary chain, it's this:
fc = round(float(fc_no_rocks)/100.0, 3) if isinstance(fc_no_rocks, str) and unicode(fc_no_rocks.replace('.','',1)).isnumeric() else round(fc_no_rocks/100.0, 3) if isinstance(fc_no_rocks, float) or isinstance(fc_no_rocks, int) else round((1+5*100)/100.0, 3)
Better to write it out in multiple lines, imo, but one-liners are such fun to write. It's like putting a bucket of water on top of a door that you know someone else is going to walk through. It sucks to be the person maintaining your code...! (By the way, make sure that you quit your job after writing this sort of stuff so that you don't have to be the one maintaining it.)
Anyway, output:
>>> fc_no_rocks = "2.3"
>>> fc = ...
>>> fc
0.023
>>> fc_no_rocks = "foobar"
>>> fc = ...
>>> fc
5.01
>>> fc_no_rocks = 1.3
>>> fc = ...
>>> fc
0.013
>>> fc_no_rocks = 6340
>>> fc = ...
>>> fc
63.4
If you want to debug right in the middle of that statement, I have good news:
>>> import sys
>>> fc_no_rocks = "foobar"
>>> fc = round(float(fc_no_rocks)/100.0, 3) if sys.stdout.write(str(type(fc_no_rocks))+"\n") or isinstance(fc_no_rocks, str) and unicode(fc_no_rocks.replace('.','',1)).isnumeric() else round(fc_no_rocks/100.0, 3) if isinstance(fc_no_rocks, float) or isinstance(fc_no_rocks, int) else round((1+5*100)/100.0, 3)
<type 'str'>
>>> fc
5.01
You can abuse the boolean or operator's behavior and the fact that the write() method always returns None! Hooray! You can also write repr(fc_no_rocks) instead if you want to see its representation - useful for getting both the contents of a string and an indication that yes, it is a string.
Edit: I'm running Python 2.7.2, so I had to add the decimal points to divide correctly. Woops!
fc_no_rocks = 1.1. So the error is somewhere else ;-)Nonesingleton using==but usingis.