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
1,954 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, 2020 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
• 58,020 points
2,475 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,510 points
828 views
+7 votes
8 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
126,926 views
0 votes
0 answers

what is a name error in python?

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

Mar 8, 2019 in Python by anonymous
1,094 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
1,482 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,230 points
1,365 views
0 votes
2 answers
+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 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,464 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
4,122 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP