Hi!
Following code is correct and executes without any problems:
I mean, the while-statements says ' while True', it will loop, as I understand it.
Now regards to this example, the program is supposed to break, when the if-statement is evaluating to the boolean value 'True' and loop if it should evaluate to the boolean value 'False'?
Basically, I would get it when the code at line 1 would say 'while not True'.
Has it maybe to do that regards to boolean algebra following is true:
if a = false and b = true, then a -> b is true?
Or why is it the the prrogram is looping in this case, while the input will be evaluated to 'False'?
regards,
Placebo
Update:
Or maybe i do get the while loops fundamentally wrong and it is like following:
When a while-statement is set to True, the program will execute the code as long as all is evaluated to true.
Only when something is evaluated to False, the code-execution will stop and loop at instructional position where it got stuck (have been evaluated to false), until the input will be evaluated to True.
Only then the program will resume and proceed the execution of the code.
Is it like that, in general?
This example also illustrates well me confusion:
https://gyazo.com/4bf66ea00cd4a5d76842dfb2224830fc
why does the program right away assume that everything is true, without any input?
Following code is correct and executes without any problems:
while True: age = input('Enter your age:\n') if age.isdecimal(): break print("Please enter a number for your age.") while True: print("Select a new password (letters and numbers only):") password = input() if password.isalnum(): break print('Passwords can only have letters and numbers.')But I want to understand why?
I mean, the while-statements says ' while True', it will loop, as I understand it.
Now regards to this example, the program is supposed to break, when the if-statement is evaluating to the boolean value 'True' and loop if it should evaluate to the boolean value 'False'?
Basically, I would get it when the code at line 1 would say 'while not True'.
Has it maybe to do that regards to boolean algebra following is true:
if a = false and b = true, then a -> b is true?
Or why is it the the prrogram is looping in this case, while the input will be evaluated to 'False'?
regards,
Placebo
Update:
Or maybe i do get the while loops fundamentally wrong and it is like following:
When a while-statement is set to True, the program will execute the code as long as all is evaluated to true.
Only when something is evaluated to False, the code-execution will stop and loop at instructional position where it got stuck (have been evaluated to false), until the input will be evaluated to True.
Only then the program will resume and proceed the execution of the code.
Is it like that, in general?
This example also illustrates well me confusion:
https://gyazo.com/4bf66ea00cd4a5d76842dfb2224830fc
why does the program right away assume that everything is true, without any input?