Python Forum

Full Version: Update indentifier of for inside this
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
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