Python Forum
Unknown Syntax Error - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Unknown Syntax Error (/thread-4787.html)



Unknown Syntax Error - AlwaysNew - Sep-08-2017

I dont know why the first line [FIRSTNAME] is a syntax error when I run the program. Screenshot link below code.
#Password Checker
import random
FIRSTNAME = input("Please enter your first name.\n")
SURNAME = input("Please enter your second name.\n")
RANUM = random.randint(10,99)
USERNAME = FIRSTNAME[0] + SURNAME[0:4] + str(RANUM)
print ("Your user name is", USERNAME)
PASSWORD = input("Please enter a Password.\n")
USERNAMECHECK = input("Please re-enter the username to log on.\n")
if USERNAME.lower() != USERNAMECHECK.lower():
    USERNAMECHECK = input("Please re-enter the username, it is incorrect:\n")
PASSWORDCHECK = input("Please re-enter the password to log on.\n")
if PASSWORD.lower() != PASSWORDCHECK.lower():
    PASSWORDCHECK = input("Please re-enter the password, it is incorrect:\n")
    
Screenshots = Print-screen


RE: Unknown Syntax Error - ichabod801 - Sep-08-2017

I'm not getting a syntax error with that code. How are you running it? Is there any other code you're not showing us?


RE: Unknown Syntax Error - AlwaysNew - Sep-08-2017

Here is the full code (not finished) I dont think anything else has reliance to the code. I am using win7 with 64 bit python 3.52 idle
 
import random

#Subrounteens
def menu():
    CHOICE = int(input("Welcome,\n [1] English Questions \n [2] Math Questions \n [3] ICT Questions \n [4] Quit/Exit \nPlease enter your choice:\n")

#Password Checker

FIRSTNAME = input("Please enter your first name.\n")
SURNAME = input("Please enter your second name.\n")
RANUM = random.randint(10,99)
USERNAME = FIRSTNAME[0] + SURNAME[0:4] + str(RANUM)
print ("Your user name is", USERNAME)
PASSWORD = input("Please enter a Password.\n")
USERNAMECHECK = input("Please re-enter the username to log on.\n")
if USERNAME.lower() != USERNAMECHECK.lower():
    USERNAMECHECK = input("Please re-enter the username, it is incorrect:\n")
PASSWORDCHECK = input("Please re-enter the password to log on.\n")
if PASSWORD.lower() != PASSWORDCHECK.lower():
    PASSWORDCHECK = input("Please re-enter the password, it is incorrect:\n")
    
#Menu
#print ("Correct!\nAcessing menu")
                 
menu()
                 
    if choice == '1':
        print ("English Questions Selected")
        Q1 = input("Q1: Who is Macbeth's Wife?\n")
        Q2 = input("Q2: Who was the old king of Scotland?\n")
        print (Q1.lower,Q2.lower)

I fixed the syntax issue by using a print and variable instead of making them in one for a subroutine is there any way I could do it in one line? 
#Subrounteens
def menu():
    print("Welcome,\n [1] English Questions \n [2] Math Questions \n [3] ICT Questions \n [4] Quit/Exit \nPlease enter your choice:\n")
    choice = int(input())



RE: Unknown Syntax Error - ichabod801 - Sep-08-2017

You're missing a close parentheses at the end of line five.

When you get a syntax error that you don't understand, always check the previous line of code and make sure everything is closed off properly.


RE: Unknown Syntax Error - AlwaysNew - Sep-09-2017

Thanks, Stupid mistake.


RE: Unknown Syntax Error - ichabod801 - Sep-09-2017

If it's a stupid mistake, then we're all stupid. The reason I was able to ask the right questions to identify the error is that I make that same mistake all the time.


RE: Unknown Syntax Error - AlwaysNew - Sep-09-2017

Yeh it just really annoys me, but the program is finished now so its all over :).


now onto the next project.