Better while loop - Python discussion
Jun 9, 2022 ... This code uses “list slicing ... If functions aren't in your toolkit yet, just program it all linearly and learn about strings and loops.
Jun 9, 2022 ... This code uses “list slicing ... If functions aren't in your toolkit yet, just program it all linearly and learn about strings and loops.
Strings (like most Python “containers”) are true if not empty and false if empty. This means that all(e) will always return True. The usual way of doing what you’re doing is very close to what you have done: loop over secret_word_copy checking that all its characters appear in letters_guessed.
My code does work, but I have two while loops of which I am not sure any one can be further simplified: class Solution: def lengthOfLongestSubstring(self, s: str) -> int: n = len(s).
Feb 5, 2024 ... I need help fixing up this while loop. When I place my answer I end up with the same answer “That is not A, B, C, D or E, ...
auto while (True): row = file.readline() if row == "" #here the variable row is recognised. Interestingly here is also "" which to me means that Python sees that part as str, no?
Feb 12, 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: ...
```python YOUR CODE HERE ```. the indents and other formatting doesn’t get preserved, which as you know is critical in Python and makes it impossible to understand what you mean without guessing. You can see if it looks like my examples in the preview.
Jun 4, 2026 ... That said, a while loop is concept related to control flow, they're not a python exclusive feature and basically any programming language uses ...
I have a task to program a ‘while loop’ that accepts input form the user that is supposed to work like this: If the user types “yes” the gam…So it is comparing a string (StartGame) for equality with a list (the list of values "no" and "yes"). They’re never going to be equal.
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 ...
Nov 3, 2023 ... = does not mean equality as it does in mathematics. To set counter to 0 you have this line of code: counter = 0. Inside the loop the value of ...