Python Forum
Update indentifier of for inside this
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Update indentifier of for inside this
#1
Hi, there is a way to change or update the identifier of for inside of this, somthing like that:

for k in range(20):
    k=1000
I try this but doesn't result, the why i need this is complicated, just tell me if is posible.

Thanks.
Reply
#2
you can *change* k, but it won't exit the loop and what is most important - if you [need to] do so, it is certain that there is something wrong with your code...Most probably - wrong type of loop
for k in range(20):
    print(k)
    k=1000
    print(k)
Output:
0 1000 1 1000 2 1000 3 1000 4 1000 5 1000 6 1000 7 1000 8 1000 9 1000 10 1000 11 1000 12 1000 13 1000 14 1000 15 1000 16 1000 17 1000 18 1000 19 1000
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question Python + Google Sheet | Best way to update specific cells in a single Update()? Vokofe 1 2,673 Dec-16-2020, 05:26 AM
Last Post: Vokofe

Forum Jump:

User Panel Messages

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