Python Forum
Need help understanding .pop
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help understanding .pop
#4
(Jul-16-2021, 03:49 PM)Akulinyak Wrote: I don't understand why after generating 0 1 2 3 sequence pop happens twice and begin from 0 1 not from 0 1 2 3 as i exepcted.

It's because the recursion doesn't run the functions one after the other, it stops in the middle.

You're running a function and get to line 22 (no POP yet). You then start another function. *It* might run to line 22 and start another function. Finally, the last one started exits.

At that point it returns and the previous function picks up where it left off at line 23. You see the POP messages. It exits and the previous function picks up (with its arguments) at line 23 also.

It's not that one function execution is popping twice, it's that you're running multiple functions simultaneously and they're all printing to the screen in an order that you don't expect.
Reply


Messages In This Thread
Need help understanding .pop - by Akulinyak - Jul-16-2021, 12:25 PM
RE: Need help understanding .pop - by Marbelous - Jul-16-2021, 02:12 PM
RE: Need help understanding .pop - by Akulinyak - Jul-16-2021, 03:49 PM
RE: Need help understanding .pop - by bowlofred - Aug-14-2021, 12:31 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020