Skip to content
murmot

Results for “while loop python example program code for adding text site:discuss.python.org”

  • discuss.python.org

    Infinite While Loop - Python Help - Discussions on Python.org

    Working on text input and outputs right now. My current code is supposed to count each letter that appears in a text document (“lyrics.txt”) and output the number of times each letter appears. The gets stuck in an infinite while loop though, and I’m not entirely sure why.

  • discuss.python.org

    How to write a loop with conditions - Python Help ...

    Jan 11, 2022 · So if you know any python expressions that evaluate to True or False, they are a perfect fit in the while loop expression. Most of those expressions will be comparisons though. But you can find all this information in any python tutorial online, first try looking up for those and then come back when something else goes wrong.

  • 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

    Nested While Loops - Python Discussions

    Oct 20, 2021 ... The following program is supposed to output numbered rows and columns (as in 1A, 1B, 1C, etc.) based on user input. If user enters 1 3, ...

  • discuss.python.org

    Help with a while loop - Discussions on Python.org

    Feb 5, 2024 · The Python docs themselves have an extensive one: Python documentation 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...

  • discuss.python.org

    How while loop wroks? - Discussions on Python.org

    Oct 19, 2022 · By starting at -1 your loop test now needs to test against size-1, which is more… complicated than size. More complication means harder to read and understand. It is also why functions like range () exist: to make it easy to use the values you want. When you’re looking for this kind of error, it helps to call print () with various ...