Hi there. So from what I know, strings are immutable, right?
So why then, does my program, return an old value. Say I type in one, then type in 1, it continues to return one, even if it's provided with a legitimate value.
The commented out line works, I just want to know why, when I call my function again, the variable "length" remains the same?
thanks
#Implementing error handling for password generator.
#Using a while loop to ensure that the correct value is entered.
length = input("Enter a length for the password (below 20 characters) \n")
is_valid = False
while not is_valid:
#Check if length can be converted to an integer.
#if it can be, then set is_valid to True and
#end the loop.
try:
int(length)
is_valid = True
#If not an integer, print message not a number and req input again.
#Ask for input again.
except ValueError:
print("That's not a number \n")
print(length)
get_password_length()
#length = input("Enter a length for the password (below 20 characters \n")
#Returns the value of length as an integer.
return int(length)```