Use of Global count instead of local count variable
Hi, I don't 100% understand why this function only works when the 'Global' keyword is used with the count variable.
Why doesn't this function work if we just declare 'count' within the function, instead of outside it? I assume it's something to do with recursion, but I'm not sure.
My solution was different from the instructor's, so I didn't need to use this global keyword.
Thanks for your help.
1 answers ( 0 marked as helpful)
if we use only count like a normal variable every time we use the recursion function, we put count = 0 but with the global variable we only call count = 0 for the first time and then only call the variable count into the function.