Skip to content
murmot

Results for “python while loop string example interview java code practice site:discuss.python.org”

  • discuss.python.org

    Sliding window question -- how to optimize the loop usage - Python...

    I have while j < n in the first while loop and also in the inner loop. I could not see a way to simplify the two while j < n statements. It seems that both need to exist. Is it common for such sliding window questions? Is there any good way to simplify based on the current code?

  • discuss.python.org

    Help with a while loop - Discussions on Python.org

    Feb 5, 2024 · The Python Tutorial Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python’s elegant syntax an... But there are many more online under a Google search for “Python tutorial” e.g. if a video tutorial is more your ...

  • discuss.python.org

    Need help understanding this while loop - Python Help ...

    Feb 13, 2024 · The while loop gets rid of the need for (this use of) goto. It’s basically combines the if statement and the two goto statements into a single piece of code that restricts where control goes next.

  • discuss.python.org

    Coding Help With Coding A Tic Tac Toe Game - #6 by CAM-Gerlach...

    variables and Python code that will be evaluated to be part of #.The return statement both #. returns the values we want and breaks the while loop #. Also, note that Python uses 0 indexing, so the first position #. in a list is 0, the second is 1, etc., whereas we humans usually #.

  • discuss.python.org

    Looking for practice while loop questions - Python Help ...

    Feb 3, 2023 · In this tutorial, you'll learn how to emulate do-while loops in Python. The most common technique to do this is to create an infinite while loop with a conditional statement that controls the loop and jumps out of it using a break statement.

  • discuss.python.org

    Writing a Linear Search algorithm - malformed string representation

    While Python does take the “everything is an object” principle very seriously, so that e.g. functions are objects, you don’t need to create a different kind of function in order to express the idea of a linear search - you just need a function that contains that logic.

  • discuss.python.org

    Help Understanding While loops - Discussions on Python.org

    Nov 3, 2023 · The way that python changes the value of a variable is to use =. = 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 counter needs to be incremented by 1 each time. counter = counter + 1 What that does is take the current value of counter, add one to it and replace the value in counter with the calculation ...

  • discuss.python.org

    How while loops affect other codes running - Python Help...

    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. In simple terms, Python runs one line of code at a time. If you start at the top of the script...

  • discuss.python.org

    While loop Problem - Python Help - Discussions on Python.org

    Jun 18, 2024 · A while loop means “repeat the following block of code until the condition is not met.” The loop is set to run while (i < 18), but then i is overwritten by i=int (input (“Enter your height:”)). So any value for height less than 18 will cause the loop to stop once it finishes the current iteration. To my eye the loop logic is a bit odd, because it at least starts examining the age (in ...

  • discuss.python.org

    How to while-loop .readline see str in the file - Python Help ...

    Jan 17, 2023 · When there’s no more data left in the (text) file, further attempts to read from it return the empty string. If the last line has no "\n" at the end then the final readline call returns a string with no newline. If it does have the "\n", that is included. In either case the file is now exhausted, and further reads will return the empty string.