Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8462981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:20:12+00:00 2026-06-10T14:20:12+00:00

I have a function checkAllInOneDirection which is a recursive loop. When I break out

  • 0

I have a function “checkAllInOneDirection” which is a recursive loop. When I break out of the loop, the function returns 1 array and 3 booleans. The weirdest thing is that within the recursive function, as it returns, it showed all of which have values yet I’m still getting the “None Type” error:

Here’s the print:

Before return : [[0, 0]] False False False False

But as it returns and before it exception out, the values of returned became

    After returned : [[0, 0]] True True True True

Although the returned values out of the recursive is changed and wrong, there’s still some value, yet I’m exception out of a “None Type” error? Here’s the error:

     File "C:\xampp\htdocs\ZoneFinding\zoneFinder2D_V2.py", line 127, in handleCheck
    finalCatch, forBoo, bakBoo, upBoo, dwnBoo = checkAllInOneDirection(finalCatch,tempCatch,recursiveCount,newCatch, columnCount, rowCount, width, height, posToCheck, forBoo, bakBoo, upBoo, dwnBoo)
TypeError: 'NoneType' object is not iterable

Here’s the function that calls the recursive “checkAllInOneDirection”.

def handleCheck(newCatch, locale, subset, width, height, rowCount, columnCount, posToCheck):
    forBoo = True; bakBoo =True; upBoo=True; dwnBoo= True; lastOneInSet =0;
    while forBoo and bakBoo and upBoo and dwnBoo :
        if locale[posToCheck[0]][posToCheck[1]] == 0:
            recursiveCount = 0; tempCatch = []; finalCatch =[]
            tempCatch.append(posToCheck)
            finalCatch, forBoo, bakBoo, upBoo, dwnBoo = checkAllInOneDirection(finalCatch,tempCatch,recursiveCount,newCatch, columnCount, rowCount, width, height, posToCheck, forBoo, bakBoo, upBoo, dwnBoo)
            replaceVal(locale, finalCatch)

    return False, finalCatch

Here’s the recursive function checkAllInOneDirection code.

def checkAllInOneDirection(finalCatch,tempCatch,recursiveCount,newCatch, width, height, forBoo, bakBoo, upBoo, dwnBoo):

    isItLast = checkLast(forBoo, bakBoo, upBoo, dwnBoo)
    if isItLast:
        for each in tempCatch:
            if not each in finalCatch:
                finalCatch.append(each)
        tempCatch=[]
        for each in newCatch:
            if not each in finalCatch:
                finalCatch.append(each)
        newCatch=[]
        print "Before return :", finalCatch, forBoo, bakBoo, upBoo, dwnBoo
        return finalCatch, forBoo, bakBoo, upBoo, dwnBoo

    for each in range (0, len(tempCatch)):
        posToCheck = posToCheckBak = posToCheckUp = posToCheckDwn = [tempCatch[each][0], tempCatch[each][1]]
        ### Some code to check position forward
        newPosForward = checkForward(posToCheck, width)
        if newPosForward != False:
            tempLocale = locale[newPosForward[0]][newPosForward[1]]
        elif newPosForward == False:
            tempLocale = 1
        if newPosForward != False and tempLocale ==0 and not newPosForward in finalCatch and not newPosForward in newCatch:
            forVal = locale[newPosForward[0]][newPosForward[1]]
            newCatch.append(newPosForward)
            posToCheck = newPosForward
            forBoo = True
        elif newPosForward == False and tempLocale == 1 and not newPosForward in newCatch:
            forBoo = False

        ### Some code to check position backward
        newPosBackward = checkBackward(posToCheckBak)
        if newPosBackward != False:
            tempLocale = locale[newPosBackward[0]][newPosBackward[1]]
        elif newPosBackward == False:
            tempLocale = 1    
        if newPosBackward != False and tempLocale ==0 and not newPosBackward in finalCatch and not newPosBackward in newCatch:
            forVal = locale[newPosBackward[0]][newPosBackward[1]]
            newCatch.append(newPosBackward)
            posToCheckBak = newPosBackward
            bakBoo = True
        elif newPosBackward == False and tempLocale == 1 and not newPosBackward in newCatch:
            bakBoo = False

        ### Some code to check position upward
        newPosUp = checkUpRow(posToCheckUp)
        if newPosUp != False:
            tempLocale = locale[newPosUp[0]][newPosUp[1]]
        elif newPosUp == False:
            tempLocale = 1
        if newPosUp != False and tempLocale ==0 and not newPosUp in finalCatch and not newPosUp in newCatch:
            forVal = locale[newPosUp[0]][newPosUp[1]]
            newCatch.append(newPosUp)
            posToCheckUp = newPosUp
            upBoo = True
        elif newPosUp == False and tempLocale == 1 and not newPosUp in newCatch:
            upBoo = False

        ### Some code to check position downward
        newPosDwn = checkDwnRow(posToCheckDwn, height)
        if newPosDwn != False:
            tempLocale = locale[newPosDwn[0]][newPosDwn[1]]
        elif newPosDwn == False:
            tempLocale = 1
        if newPosDwn != False and tempLocale ==0 and not newPosDwn in finalCatch and not newPosDwn in newCatch:
            forVal = locale[newPosDwn[0]][newPosDwn[1]]
            newCatch.append(newPosDwn)
            posToCheckDwn = newPosDwn
            dwnBoo = True
        elif newPosDwn == False and tempLocale == 1 and not newPosDwn in newCatch:
            dwnBoo = False

    for each in tempCatch:
        if not each in finalCatch:
            finalCatch.append(each)
    tempCatch =[]
    for each in newCatch:    
        if not each in finalCatch:
            finalCatch.append(each)
            tempCatch.append(each)
    newCatch = []

    checkAllInOneDirection(finalCatch,tempCatch,recursiveCount,newCatch, width, height, forBoo, bakBoo, upBoo, dwnBoo)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T14:20:14+00:00Added an answer on June 10, 2026 at 2:20 pm

    I think you want the last line to be:

    return checkAllInOneDirection(...)
    

    instead of just:

    checkAllInOneDirection(...)
    

    After you fall off the end of that statement, the function returns. As it has no explicit return statement, it returns None.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have function getMemory() which returns VARIANT (mfc). It is said that in ulVal
Inside my Controller i have function that runs after user clicks on item, which
I have function that have been colled in stored procedure. The function returns a
I have function in my database class that returns the id of the people
I have function that returns the index of a character GetCharFromPos(Pt: TPoint): Integer; now
I have function getCartItems in cart.js and I want to call that function in
I have function Start() that is fired on ready. When I click on .ExampleClick
I have function some_func_1 which will create an object of type some_type and will
i have function which return list as given below. List<User> lstUsers = SearchUsers(searchText); which
i have function, which has to accept two types of data - Observable collection

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.