What exactly is invalid syntax error?

0 votes
Isnt it same as a nameerror, there also we make a mistake in the syntax so why not get a invalid syntax error instead?
Jun 12, 2019 in Python by Waseem
• 4,540 points
322 views

1 answer to this question.

0 votes

please solve this error

 

def TakeImages():
    Id=(text.get())
    name=(text2.get())
    if(is_number(Id) and name.isalpha()):
        cam=cv2.VideoCapture(0)
        harcascadePath = "haarcascade_frontalface_default.xml"
        sampleNum=0
        while(True):
            ret,img= cam.read()
            gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
            faces= detector.detecMultiScale(gray,1.3,5)
            for (x,y,w,h) in faces:
                cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0,2)  
                 sampleNum = sampleNum+1                 
                cv2.imwrite("TrainingImages\ "+name +" "." + Id + '.' +str(sampleNum) + ".jgp", gray[y:y+h,x:x+h])
                cv2.imshow('Frame',img)
            if cv2.waitKey(100) & OxFF "" ord('q'):
                            break
            elif sample>60:
                break
        cam.release()
        cv2.destroyAllWindows()
        res = "Images Saved or ID: " Id + "Name : "+ name
        row = [Id,name]
        with open('StudentDetails\studentDetails.csv', 'a+') as csvFile:
             writer = csv.writer (csvFile)
             writer.writerow(row)
        csvFile.close()
        message.configure(text=res)
    else:
          if(is_number(Id)):
                res ="Enter Alphabetical Name"
                message.configure(text=res)
          if (name.isalpha()):
                res="Enter numeric Id"
                message.configure(text=res)                         
                                         
        cv2.destroyAllWindows()

File "<ipython-input-90-4efc38272594>", line 14 sampleNum = sampleNum+1 ^

SyntaxError: invalid syntax

answered Jul 20 by Prince kumar

Related Questions In Python

0 votes
1 answer

'Syntax Error: invalid syntax' for no apparent reason

You're missing a close paren in this ...READ MORE

answered Aug 13, 2018 in Python by Priyaj
• 57,640 points
664 views
0 votes
1 answer

What is getattr() exactly and how do I use it?

You can view a full example here: http://www.diveintopython.net/power_of_introspection/index.html Introspection ...READ MORE

answered Sep 17, 2018 in Python by bug_seeker
• 15,480 points
83 views
+6 votes
6 answers

What exactly is the function of random.seed() in python?

The seed method is used to initialize the ...READ MORE

answered Oct 29, 2018 in Python by Rahul
87,724 views
0 votes
0 answers

what is a name error in python?

why am i getting a name error ...READ MORE

Mar 7, 2019 in Python by anonymous
435 views
0 votes
1 answer

what is a type error in python?

you get a type error when you ...READ MORE

answered Mar 8, 2019 in Python by Waseem
• 4,540 points
256 views
0 votes
1 answer

what is attribute error in python?

import pandas df = pd.read_csv('filename') it will give attribute ...READ MORE

answered Mar 27, 2019 in Python by Mohammad
• 3,210 points
593 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,350 views
0 votes
0 answers
+4 votes
6 answers