python 3.x - resetting the parameters of a for loop from inside the loop in Python3 -


I am working as a fun way to learn the language through Project Euler problems in Python 3, and the problem My solution of the number three I think is a small cowardice problem is the biggest factor of 600851475143, and I have solved it in a very wonderful way:

  #! / Usr / local / bin / python3 # encoding: utf-8 # which is the main key factor of the user type def main (): original = int (input ("input a number:")) if the original == isPrime ( Original): print (origin, "prime") and second: print (factor (original), "biggest major factor", original) DF factor (number): nummy = number for the number (nummy, number) : If (number% number == 0 and isPrime (num)) == number: largest = int (num) number = int (number / largest) nummy = int (biggest + 2) print ("so far , ", Most Yes, "the biggest prime factor is ...") if the number & lt; Largest: Break Return is the largest def: Value (value): range for the number (2, int (value ** 0.5) +1): If the value is% num == 0: return int (value / number) return value if __name__ == "__man__": main ()   

As you can see, in my "Factor" function, I tried to update the upper border limit in my loop, but It did not really work as I was expecting, so I had to add that number; The biggest block gets the whole thing to run in a fair amount

Is there any way to update loop parameters from inside the loop?

I appreciate any information on this.

class (number, number) before evaluating it for loop, so in your case this is not possible.

Generally in Python (though not always) possible, but it is a bad idea. It is better to check out the changed positions and get out of the loop as you did.

Comments