Please advise the correct code: Main class: StretchWith2Vowels Read sentences from the user until * is entered. Show the number of words in each sentence that contain a stretch of non-z characters with exactly 2 vowels. A stretch starts from the start of the word or after a 'z'. A stretch terminates just before another 'z' or at the end of the word. Examples: Matching words: zoo, azozooza, GONZALEZNon-matching words: ozo, azoooza The sentences contain no punctuation, the words are separated by one or more spaces, and the characters may be upper or lower case. Keep reading sentences until the user enters "*". Sample I/O: Sentence: azoooza azooza zoo azoo Matching words = 3 Sentence: GONZALEZ passes the ball to VAZQUEZ Matching words = 3 Sentence: azozototzeti Matching words = 1 Sentence: * Done My code: function for checking a word def match(s): # firsty lower the case of the word s=s.lower() # count the occurence of vowels if(s.count('a') + s.count('e') + s.count(i) + s.count(o) + s.count(u)==2): # if its 2 return true return True # IF COUNT OF Z=0 RETURN FALSE if(s.count('z')==0): return False # ELSE SPLIT THE WORD IN Z s=s.split("z") # CALL THE FUNCTION FOR EACH STRECH IN S for i in range(len(s)): # IF FOUND A STRECH FULLFILLING THE CONDITION RETURN TRUE if(match(s[i])==True): return True # ELSE RETURN FALSE return False # FUNCTION FOR CALCULTING TOTAL MATCHING WORDS def totalMatching(s): # SPLIT THE SENTENCE s=s.split(' ') # INITIALIZE COUNT TO 0 count=0 # LOOP FROM 0 TO LENGTH OF S for i in range(len(s)): # CALL THE MATCH FUNCTION FOR EACH WORD if(match(s[i])==True): # IF WORD SPECIFIES THE CRIETIRA INC COUNT count+=1 # RETURN COUNT AFTER CHECKING return count # WHILE TRUE while(True): # INPUT THE SENTENCE s=input("Sentence : ") # IF * BREAK THE LOOP if(s=="*"): print("Done") break # ELSE CALL MATCHING FUNCTION AND PRINT THE ANSWER print("Matching words : ",totalMatching(s)) My output: Sentence : I went to the zoo Traceback (most recent call last): File "/home/StretchWith2Vowels.py", line 45, in print("Matching words : ",totalMatching(s)) ^^^^^^^^^^^^^^^^ File "/home/StretchWith2Vowels.py", line 31, in totalMatching if(match(s[i])==True): ^^^^^^^^^^^ File "/home/StretchWith2Vowels.py", line 6, in match if(s.count('a') + s.count('e') + s.count(i) + s.count(o) + s.count(u)==2): ^ UnboundLocalError: cannot access local variable 'i' where it is not associated with a value Expected output: Sentence: I went to the zoo Matching words = 1 Sentence: * Done