Python Forum

Full Version: raw_input
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am brand new to python and seem to to stuck on something that seems simple. If I run the code below it works as expected.

money = -10
print money
if money == 0:
   print 'You got no money'
elif money < 0:
   print 'Sorry about your luck'
else:
   print 'Yeah you got money'
However if I add raw_input it ignores all conditions and prints else.

money = raw_input('How much money do you have? ')
print money
if money == 0:
   print 'You got no money'
elif money < 0:
   print 'Sorry about your luck'
else:
   print 'Yeah you got money'
Any help would be appreciated.
Please post your code with BB Code (use the python button)

this works (for me) in python 2 & 3

money = int(input('How much money do you have? '))
print (money)
if money == 0:
    print ('You got no money')
elif money < 0:
    print ('Sorry about your luck')
else:
    print ('Yeah you got money')
I have now been able to get it to work.

Thanks for the reply and converting the raw_input to float seemed to work
(Sep-26-2018, 03:58 PM)rtbr17 Wrote: [ -> ]I am brand new to python
You should definitely upgrade to python 3.x. Your code indicates you're using 2.x, which is in bugfix-only mode, and nearing the end of even that.

*edit* more info: https://pythonclock.org/