#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    2
    Rep Power
    0

    No idea how to solve simple syntax error


    Hey everyone! First post! Also I am a newbie with python, so sorry if this is a very simple error, but I simply have no idea what to do. I am just begning this program but it won't even run, when I attempt to run it it highlights in red the : symbol just after the line that says

    if answr_str == "e":

    Then a box pops up saying syntax error. I've reviewed all basic rules and have no idea what I'm doing wrong. Any advice is appreciated!



    #Welcome messages
    print("This program was created for generating ciphered and deciphered alphabets")
    print("The program begins with a numerical index for the ordinary alphabet")
    print("Then this index is altered based on a specified input from you!")

    while True :

    # Program begins by prompting user for a specific input

    answr_str = input("Enter 'e,' 'd,' or 'q,' (lower case only) respectively, to encode, decode, or quit the program. "

    if answr_str == "e":
    print("You have chosen to encode")
    encode = answr_str
    elif answr_str == "d":
    decode = answr_str
    print("You have chosen to decode")
    elif answr_str == "q":
    q = answr_str
    print("Thanks for usinig my program")
    break
    else
    print("Acceptable inputs are 'e,' 'd,' or 'q'")
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Location
    Tewksbury, MA
    Posts
    39
    Rep Power
    2
    Code:
    answr_str = input("Enter 'e,' 'd,' or 'q,' (lower case only) respectively, to encode, decode, or quit the program. "
    You forgot the last closing parentheses.

    BTW, when posting code, select it and press the code tags button (#).
  4. #3
  5. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2005
    Posts
    611
    Rep Power
    65
    Assuming you used the proper indentations, there is a closing ) missing in line
    answr_str = input(....)

    also else needs a :
    Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    2
    Rep Power
    0
    Wow! what a silly mistake!! And ok yeah I'm new to this, but thanks alot!
  8. #5
  9. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,905
    Rep Power
    481
    An editor such as emacs matches closing braces of whatever style in many languages.
    [code]Code tags[/code] are essential for python code and Makefiles!
  10. #6
  11. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Location
    Tewksbury, MA
    Posts
    39
    Rep Power
    2
    Originally Posted by b49P23TIvg
    An editor such as emacs matches closing braces of whatever style in many languages.
    I use PyScripter a lot and it has that feature. I turn off automatically completing brackets but having it highlight the pairs is great.

IMN logo majestic logo threadwatch logo seochat tools logo