Skip to content
murmot

Results for “python while loop string example site:wiki.python.org code”

  • wiki.python.org

    For Loop - Python Wiki

    string = "Hello World" for x in string: print(x). Lists as an iterable ... Python for loop and while loop tutorial with interactive code examples. Back ...

  • wiki.python.org

    While loops - Python Software Foundation Wiki Server

    While loops Usage in Python When do I use them? While loops, like the ForLoop, are used for repeating sections of code - but unlike a for loop, the while loop will not run n times, but until a defined condition is no longer met. If the condition is initially false, the loop body will not be executed at all. As the for loop in Python is so powerful, while is rarely used, except in cases where a ...

  • wiki.python.org

    Powerful Python One-Liners - Python Wiki

    The source code is contributed from different Python coders — Thanks to all of them! ... python string and list methods. Here is an example from the homepage:.

  • wiki.python.org

    For Loop - Python Wiki

    The Python for statement iterates over the members of a sequence in order, executing the block each time. Contrast the for statement with the ‘’while’’ loop, used when a condition needs to be checked each iteration or to repeat a block of code forever. For example: For loop from 0 to 2, therefore running 3 times.

  • wiki.python.org

    Python Speed / Performance Tips

    you can use map to push the loop from the interpreter into compiled C code: ... Here's a contrived example written in Python. import time x = 0 def doit1(i): ...

  • wiki.python.org

    Perl Phrasebook - Python Wiki

    looping over files given on the command line or stdin¶. The useful Perl idiom of: while (<>) { ... # code for each line }. loops over each line of every file ...

  • wiki.python.org

    Simple Programs - Python Wiki

    Simple Programs ¶ Legacy Wiki Page This page was migrated from the old MoinMoin-based wiki. Information may be outdated or no longer applicable. For current documentation, see python.org. The examples below will increase in number of lines of code and difficulty: 1 line: Output ... 2 lines: Input, assignment ... 3 lines: For loop, built-in ...

  • wiki.python.org

    Templating - Python Wiki

    ... python code. It does this by implementing a quoted-string data type and a modification of the python compiler. Quik - A fast and lightweight Python template ...

  • wiki.python.org

    Handling Exceptions - Python Wiki

    Python supplies that infrastructure for you, in the form of exceptions. (I’m sorry, but if you had actually done much programming in C++, you’d know that there’s not much difference between the two languages when it comes to exceptions, at least unless you program C++ in the old-fashioned C-like way with new’s and delete’s sprinkled ...

  • wiki.python.org

    Python Decorator Library

    Please make sure example code conforms with PEP 8. Creating Well-Behaved Decorators / “Decorator decorator”¶. Note: This is only one recipe. Others include ...

  • wiki.python.org

    Beginners Guide / Examples - Python Wiki

    Python Examples and Sample Code ¶ When you’re learning, small examples can be very helpful. The Python Standard Library (archived copy), an electronically published book by Fredrik Lundh, examines most of the modules in Python’s standard library, describing what the module does and giving a short example of its use. Note that this book is now relatively old and so misses a lot of the ...

  • wiki.python.org

    Beginners Guide / Overview - Python Wiki

    While Loop · GUI Programming · Guides and How-Tos · Internationalization · Python ... Python's interactive mode makes it easy to test short snippets of code.