About 323,000 results
Open links in new tab
  1. python - How can I access the index value in a 'for' loop ... - Stack ...

    The fastest way to access indexes of list within loop in Python 3.7 is to use the enumerate method for small, medium and huge lists. Please see different approaches which can be used to …

  2. Example use of "continue" statement in Python? - Stack Overflow

    In the example above if I use break the interpreter will skip the loop. But with continue it only skips the if-elif statements and go directly to the next item of the loop.

  3. What is the purpose of the single underscore "_" variable in Python?

    May 5, 2011 · An unused variable is often hiding a bug/typo (e.g. set day but use dya in the next line). The pattern matching feature added in Python 3.10 elevated this usage from …

  4. When to use "while" or "for" in Python - Stack Overflow

    Dec 27, 2022 · When I should use a while loop or a for loop in Python? It looks like people prefer using a for loop (for brevity?). Is there any specific situation which I should use one or the …

  5. Use a loop to plot n charts Python - Stack Overflow

    Use the argument block=False only if you want to pop up all the plots together (this could be quite messy if you have a lot of plots). You can do this inside the loop_plot function or in a separate …

  6. python - Get loop count inside a for-loop - Stack Overflow

    Get loop count inside a for-loop [duplicate] Asked 15 years, 5 months ago Modified 3 years, 7 months ago Viewed 654k times

  7. Best way to loop over a python string backwards

    Aug 9, 2015 · What is the best way to loop over a python string backwards? The following seems a little awkward for all the need of -1 offset: string = "trick or treat" for i in range(len(string)-1, 0 …

  8. python - How can I use `return` to get back multiple values from a …

    Jul 4, 2020 · This question has become a canonical duplicate target for questions about returning multiple values from code including a for loop. As such, I have edited it somewhat artificially, to …

  9. Why does python use 'else' after for and while loops?

    Feb 13, 2016 · Almost 10 years after this question has been asked and after programming with Python for 3 years, this is the first time I've seen the "for-else", "while-else" construct. I hope its …

  10. iteration - How to loop backwards in python? - Stack Overflow

    I can think of some ways to do so in python (creating a list of range(1,n+1) and reverse it, using while and --i, ...) but I wondered if there's a more elegant way to do it.