Aug-02-2020, 02:21 PM
Recursion is when a function calls itself. Your functions should not call themselves. searching should not call searching() and website should not call website(). Recursion can be used to solve lots of interesting problems, but yours is not one of them. You should use loops.
Recursion is causing your program to crash because Python puts a limit on how "deep" the recursion can go. Each recursive function call uses a bunch of memory. The memory is used to save information about what the function was doing (program counter, variable values, etc) so this can be restored when the function call returns. Left unchecked your program would use all available memory and crash, and probably cause other programs to crash. Your searching() function makes one string and then calls itself, making another string and then calling itself to make another.....
Instead of recursively calling itself your searching function should generate a string, test if that is a website, add the website if the test passes, and repeat over and over. Written this way, with a loop, it could run forever because it does not continuously consume more and more memory saving context information for yet another function call.
Recursion is causing your program to crash because Python puts a limit on how "deep" the recursion can go. Each recursive function call uses a bunch of memory. The memory is used to save information about what the function was doing (program counter, variable values, etc) so this can be restored when the function call returns. Left unchecked your program would use all available memory and crash, and probably cause other programs to crash. Your searching() function makes one string and then calls itself, making another string and then calling itself to make another.....
Instead of recursively calling itself your searching function should generate a string, test if that is a website, add the website if the test passes, and repeat over and over. Written this way, with a loop, it could run forever because it does not continuously consume more and more memory saving context information for yet another function call.