Skip to content
murmot

Results for “python while loop string methods examples list site:wiki.python.org 2”

  • wiki.python.org

    ForLoop

    There are two ways to create loops in Python: with the for-loop and the while-loop. When do I use for loops.Basically, any object with an iterable method can be used in a for loop. Even strings, despite not having an iterable method - but we'll not get on to that here.

  • wiki.python.org

    Powerful Python One-Liners - Python Wiki

    index() method). 1 # List 2 lst = [1, 2, 3, 'Alice', 'Alice'] 3 4 # One ... python string and list methods. Here is an example from the homepage: Here ...

  • wiki.python.org

    PythonSpeed/PerformanceTips

    Here's a straightforward example. Instead of looping over a list of words and converting them to upper case: newlist = [] for word in oldlist: newlist.append(word.upper()).newlist = map(str.upper, oldlist). List comprehensions were added to Python in version 2.0 as well.

  • wiki.python.org

    Perl Phrasebook - Python Wiki

    In Python, string methods are often used where Perl would use a regex. ... We want to add two strings to the list of strings indexed by the name flintstones .

  • wiki.python.org

    Python Speed / Performance Tips

    (Python automatically shares one- and two-character strings.) In the minus ... example requires storing a mutable counter, for example a one-element list.

  • wiki.python.org

    Handling Exceptions - Python Wiki

    But so are for loops, while loops, functions and methods! Like those other ... In the case of Python, calling a function that may raise an exception is ...