PDA

View Full Version : Does this work



EnderDas
03-21-2016, 03:40 AM
Das here....
Can someone tell me if this code works Im not near a computer right now and the console on my phonend doesn't support this syntax (-_- don't know why...)
It's python 3.5.1


data_1 = raw_input ("1+1= : ")
if (% = 2 % data_1)
print ("Correct!!")
else:
print ("Incorrect")

raqk
03-21-2016, 03:53 AM
You should be able to test it here: https://repl.it/languages/python3

I'm getting an invalid syntax error.

EnderDas
03-21-2016, 04:21 AM
I'm using Python 2.7, and your if statement isn't working.

But if I change it to



data_1 = raw_input ("1+1= : ")
if "2"==data_1:
print ("Correct!!")
else:
print ("Incorrect")


then it works.
(As long as you enter 2 exactly.)



repl.it says raw_input isn't defined even though it's a built in function, so I don't know what's going on with that.


Edit: Oh, I just noticed you said you're (OP) using python 3.5. Whatever.
I just don't know if the raw_input is right within the if statement

Also it's weird any console I use exept for regular 3.5.1 python console
It doesn't say raw_input is a thing I don't get it

EnderDas
03-21-2016, 04:26 AM
raw_input is before the if statement. Which is where it should be if you want anything to happen.

Anyway, I changed my other post. Go read it again.

I know I saw it

EnderDas
03-21-2016, 04:31 AM
raw_input is not input().

-_- yup I know

MyLegGuy
03-21-2016, 04:33 AM
-_- yup I know
I'm sorry, that was a typo. I meant to say that raw_input is now input. So just replace raw_input with input, fix your if statement, and you'll be done.

Here's how I did that:



data_1 = input ("1+1= : ")
if "2"==data_1:
print ("Correct!!")
else:
print ("Incorrect")


If mobile devices support it, maybe you can try it here:
https://repl.it/ByH1/0


I seem to make that typo a lot even though w and t are nowhere near each other on the keyboard, and this isn't the first time I've confused somebody because of it. :(

EnderDas
03-21-2016, 04:36 AM
I'm sorry, that was a typo. I meant to say that raw_input is now input. So just replace raw_input with input, fix your if statement, and you'll be done.

Here's how I did that:



data_1 = input ("1+1= : ")
if "2"==data_1:
print ("Correct!!")
else:
print ("Incorrect")


If mobile devices support it, maybe you can try it here:
https://repl.it/ByH1/0


I seem to make that typo a lot even though w and t are nowhere near each other on the keyboard, and this isn't the first time I've confused somebody because of it. :(

Oh... thx..... m8