Need help understanding this while loop - Python discussion
Feb 13, 2024 ... I'm new to while loops, and I don't quite get what's going on in this code from my book: current_number = 1 while current_number <= 5: ...
Feb 13, 2024 ... I'm new to while loops, and I don't quite get what's going on in this code from my book: current_number = 1 while current_number <= 5: ...
while is_word_guessed(secret_word, letters_guessed) == True: just to see if the change from True to None would break the loop. Anyway, any help pertaining to the mentioned function call or its use within the code as a whole would be greatly appreciated!
Nov 8, 2022 ... The next thing I would do, is the gather all the user inputs (or data) ... error will be raised by code itself if value is not within boundaries:
Python knows that the final print() is not part of the loop body because it is back at the same indent as the while statement itself. If there are changes of indent but no associated control structure like an if or while to cause the new indent, that’s an indentation error.
Dec 21, 2022 ... The while loop does not effect code outside the loop except that changes to variables and data inside the loop will be seen outside the loop ...
If defining functions inside a loop is done, does that make the function local to that loop? Here is an example: while TrueIf you’re wanting to terminate the while loop early, that test needs to be in the while loop code. Usually we’d examine the return value from the function.
Jun 9, 2022 ... Hi @Naadiyaar :slight_smile: Could you please tell us more information about the data your script manages, and the desired outputs? Cheers.
If the code doesn’t do anything, that means it remains stuck in the while True: loop, and never hits any print statements.remember, i is a string, such as 'millennium'. This is why you need meaningful names. If you’d ever hit this bit of code Python would have thrown an error.
Feb 10, 2022 ... Have you tried break instead of pass ? That should break the while loop. ... thanks for the help! Home · Categories ...
I have a problem with saving values to file using write(), essentially the program accepts 3 numerical values then stores them as strings in a textfile labeled “scores.txt”.
Jan 28, 2023 ... You don't import time , though I suspect that you didn't copy the code exactly as you've been running it (there's a stray < there too).
Jul 12, 2023 ... Hello, I have a problem with 'while' in the following code: for ... For example, you can use a string (you get one character each time) ...