Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
for-loop issue
#1
I have a function with a for-loop containing a large (32) number of statements. But, the for-loop performs only 1 iteration. I double checked the code several times and did not see anything that will make it just go once.
Is there a limit to how many statements can be contained within a for-loop ?
Reply
#2
There is no such limit in a for loop. There must be a logical error in code that makes the loop break too early. Very likely you will find it yourself, if you take the time to inspect and debug the code a bit. If that fails, feel free to post the code here (in Python code tags), and we'll help out.
Reply
#3
You can try the builtin debugger to see what's happening. python -m pdb your-file.py
Once it starts up, you'll have a prompt. Type step (or s for short) to step through your code line by line, so you can find out exactly when the loop stops looping.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  For List Loop Issue Galdain 2 2,090 Dec-31-2019, 04:53 AM
Last Post: Galdain
  issue with updating list every iteration of a loop ftrillaudp 2 3,101 Oct-29-2018, 03:23 AM
Last Post: ftrillaudp
  while loop issue, help please? itmustbebunnies 6 3,059 Oct-25-2018, 07:22 AM
Last Post: itmustbebunnies
  Issue with my 'roll the dice simulation'-exercise (cannot break out of the loop) Placebo 2 3,543 Sep-30-2018, 01:19 PM
Last Post: Placebo
  while loop issue - stuck in the loop! EricMichel 6 8,676 Aug-06-2018, 03:59 PM
Last Post: EricMichel
  Loop issue onenessboy 11 6,814 Mar-03-2018, 08:40 AM
Last Post: onenessboy
  While loop issue CWatters 4 3,839 Sep-25-2017, 08:58 PM
Last Post: nilamo
  Code issue with time remaining loop. Python3 deboerdn2000 11 8,897 May-04-2017, 04:53 PM
Last Post: deboerdn2000

Forum Jump:

User Panel Messages

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