Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
raw_input
#1
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.
Reply
#2
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')
Reply
#3
I have now been able to get it to work.

Thanks for the reply and converting the raw_input to float seemed to work
Reply
#4
(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/
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Going thru tutorials..."NameError: name 'raw_input' is not defined" hmonnier 4 4,229 Jul-14-2020, 02:19 PM
Last Post: BitPythoner
  raw_input vs input EmilySenechal 1 2,359 Nov-20-2018, 02:13 AM
Last Post: ichabod801
  URL via raw_input, passed to HTTP requests and output? johnnyaustin 1 4,890 Dec-08-2017, 11:22 PM
Last Post: johnnyaustin
  Help with raw_input Marshall_99 2 3,432 Mar-21-2017, 01:44 AM
Last Post: Marshall_99
  Cmd Module + raw_input tab [complete ruggierom 1 3,488 Feb-06-2017, 12:43 AM
Last Post: ruggierom
  Any way to get raw_input to work in my function? Pythonerous 4 5,236 Oct-27-2016, 05:03 PM
Last Post: Pythonerous

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020