Mar-19-2021, 07:54 PM
(This post was last modified: Mar-19-2021, 07:54 PM by deanhystad.)
Can't say for sure. You need to wrap code in Python tags or the indentation is lost. You should also describe what the code is supposed to do. This can be difficult for others to infer if all they have is the code which is not doing what it is supposed to do.
The way your code is written the loop is going to not execute at all or execute forever. Lets say the user types 'd'.
If the user enters 'k', k != 'd' is True, so the loop continues to execute forever. The print statement is never reached.
What is this code supposed to do?
The way your code is written the loop is going to not execute at all or execute forever. Lets say the user types 'd'.
while 'd' != 'd': if ans==k: hads=random.randint(1,hads) else: hads=random.randint(hads,99) print (hads)'d' != 'd' is False, so the loop does not run at all and the print(hads) statement executes immediately.
If the user enters 'k', k != 'd' is True, so the loop continues to execute forever. The print statement is never reached.
What is this code supposed to do?