Results 1 to 7 of 7

Thread: Does this work

  1. #1
    Lesser Wizard EnderDas's Avatar
    Join Date
    Feb 2016
    Location
    Dasville
    Posts
    154

    Default Does this work

    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
    Code:
    data_1 = raw_input ("1+1= : ")
    if (% = 2 % data_1)
      print ("Correct!!")
    else:
      print ("Incorrect")
    Last edited by EnderDas; 03-21-2016 at 03:41 AM. Reason: Forgot to add raw_input above it

  2. #2
    raqk
    Guest

    Default

    You should be able to test it here: https://repl.it/languages/python3

    I'm getting an invalid syntax error.

  3. #3
    Lesser Wizard EnderDas's Avatar
    Join Date
    Feb 2016
    Location
    Dasville
    Posts
    154

    Default

    Quote Originally Posted by MyLegGuy View Post
    I'm using Python 2.7, and your if statement isn't working.

    But if I change it to

    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

  4. #4
    Lesser Wizard EnderDas's Avatar
    Join Date
    Feb 2016
    Location
    Dasville
    Posts
    154

    Default

    Quote Originally Posted by MyLegGuy View Post
    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

  5. #5
    Lesser Wizard EnderDas's Avatar
    Join Date
    Feb 2016
    Location
    Dasville
    Posts
    154

    Default

    Quote Originally Posted by MyLegGuy View Post
    raw_input is not input().
    -_- yup I know

  6. #6
    Master Sorcerer MyLegGuy's Avatar
    Join Date
    Mar 2014
    Location
    United States
    Posts
    1,631

    Default

    Quote Originally Posted by EnderDas View Post
    -_- 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:


    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. :(

  7. #7
    Lesser Wizard EnderDas's Avatar
    Join Date
    Feb 2016
    Location
    Dasville
    Posts
    154

    Default

    Quote Originally Posted by MyLegGuy View Post
    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:


    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

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •