Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

string problems

Name: Anonymous 2013-05-06 4:51

hey guys having some issues with a program

a = float (raw_input ("enter int or float: "))

with this piece of code, every time the input is randomly a string it crashes my program, is there any way to tell python that it's okay to be a string and ignore it????

i was thinking something like....
type (a)
if a == <type 'str'>...IGNORE IT!
...and so on and so forth

didn't seem to work.. any ideas/

Name: Cudder !MhMRSATORI!fR8duoqGZdD/iE5 2013-05-06 6:23

If you're using Python, I feel bad for you son
It's got 99 problems but strings ain't one.

Name: Anonymous 2013-05-06 7:08

>>1
I think I saw this on another site once, and they said something like you need to satanise your input.

Name: Anonymous 2013-05-06 7:32

satanise your input
lel, it's like reverse taint checking

Name: Anonymous 2013-05-06 11:52

so hard right now XDXDDDDDXDDDDDDDDDDDDDDDDDD

Name: Anonymous 2013-05-06 14:06

me too
;D

Name: Anonymous 2013-05-06 14:13

egigiigigigignegiegnegiergnegrgregergge gor

Name: Anonymous 2013-05-06 22:10

type cast
cin >> float(<str>);

Name: Anonymous 2013-05-06 22:13

>>8
in python
storred_input_variable = float(<str>)

Don't change these.
Name: Email:
Entire Thread Thread List