Input wont work with if statement if it has a space
emile
emile at fenx.com
Tue Mar 5 18:47:31 EST 2013
On 03/05/2013 03:33 PM, eli m wrote:
> On Tuesday, March 5, 2013 3:31:13 PM UTC-8, eli m wrote:
>> Hi guys, i have a program like this: (A lot of code is not included)
>>
>> run = 0
>>
>> while run == 0:
>>
>> function = raw_input("Type in a function:")
>>
>> if function == "Example":
whenever function isn't _exactly_ "Example" the else clause executes.
If you want to catch forms of example you might try:
if function.strip().upper() == "EXAMPLE":
Emile
>>
>> print ("Hello World!")
>>
>> else:
>>
>> print ("blah blah blah")
>>
>>
>>
>> The problem is that whenever i type in example with a space after it then it prints the else statement.
>>
>>
>>
>> My question is, how do i get it to except input with spaces?
>
> oops i meant function = raw_input("Type in a function:")
>
More information about the Python-list
mailing list