Oops, I Did It Again (But this time I vaguely remembered)
The below code-output image does not represent the continued presence of the error I want to discuss here.
After a 'bit' of debugging (I'm kidding it took longer than that) a vague memory slowly crept out from some deep recess in my brain. Hey fool! You've run into this error before. You can't do that. You can't directly access the counter of a FOR LOOP in Python. So you can't use it as an index inside your FOR loop.
Although the error was being flagged out by my PyCharm IDE in its usual 'cryptic' manner, I didn't initially understand. The IDE said something about trying to use a set in place of an integer as an index. Finally I realized and decided to work around it by use a separate variable as my up ticking index in the loop. It worked. I got this (below):
What I was trying to do was to generate a 'Help' box by stepping through a bunch of inner lists nested inside an outer list while using the counter of my FOR loop as well as using my recently revised PPRINT() function -- which function, BTW, is being described inside the Help box. (Yes the program needs some more fixing up to make it pretty. I'll take care of it later. )
The Gemini explanation for why you can't use the for loop counter is in the below link.
I need to study up on it some more. Not yet fully understood.
QAB ::: Counter of FOR LOOP is NOT accessible in python
TO BE CONTINUED ...
MORE TO EXPLORE
After a 'bit' of debugging (I'm kidding it took longer than that) a vague memory slowly crept out from some deep recess in my brain. Hey fool! You've run into this error before. You can't do that. You can't directly access the counter of a FOR LOOP in Python. So you can't use it as an index inside your FOR loop.
Although the error was being flagged out by my PyCharm IDE in its usual 'cryptic' manner, I didn't initially understand. The IDE said something about trying to use a set in place of an integer as an index. Finally I realized and decided to work around it by use a separate variable as my up ticking index in the loop. It worked. I got this (below):
What I was trying to do was to generate a 'Help' box by stepping through a bunch of inner lists nested inside an outer list while using the counter of my FOR loop as well as using my recently revised PPRINT() function -- which function, BTW, is being described inside the Help box. (Yes the program needs some more fixing up to make it pretty. I'll take care of it later. )
I need to study up on it some more. Not yet fully understood.
QAB ::: Counter of FOR LOOP is NOT accessible in python


Comments
Post a Comment