I'm using Python 3.5. I'm using a while loop, and changing a variable inside of it (that was already defined by the user) that the user inputs:
variable = eval(input("[...]"))
while [input isn't what the user is expected to enter]:
variable = eval(input("[Asking to enter a correct input]"))
So the loop ends when the user has entered a correct value. However, as "variable" is defined inside the while loop, when the user assigns a correct value to "variable" the loop ends and the first (and incorrect) value of "variable" is considered for the rest of the program.
How can I make it so the value that is remembered is that defined inside the while loop?
while
andfor
loops don't create a new scope in Python. – jonrsharpeeval()
is a huge security issue, are you ? – bruno desthuilliers