Skip to content
Advertisement

How To Recurisve JSON file without any loop (like:for,while,etc) in Python

I’m confuse how to create recursive function to print JSON file without any loops in Python3.

So i have home work from my college, the subject is about recursion in function, the lecturer told me to to use recursion only instead of loops.

My json file in Category.json is:

JavaScript

My python code is:

JavaScript

I’m not finishing my code because i’m still confuse how to do recursion without loops.

Do you have any idea?

Advertisement

Answer

I don’t understand why you need to use recursion just to print a JSON file instead of iterations(for, while).

This is how you print your data using Recursion.

JavaScript
JavaScript

Do you know that Recursion uses something called as a Recursion Stack internally ?

That’s some extra space overhead with recursive codes.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement