About 8,510,000 results
Open links in new tab
  1. Python: next() function - Stack Overflow

    Python: next () function Asked 15 years, 11 months ago Modified 2 years, 5 months ago Viewed 64k times

  2. Python list iterator behavior and next(iterator) - Stack Overflow

    May 29, 2013 · So 0 is the output of print(i), 1 the return value from next(), echoed by the interactive interpreter, etc. There are just 5 iterations, each iteration resulting in 2 lines being …

  3. How can I do a line break (line continuation) in Python (split up a ...

    319 From PEP 8 -- Style Guide for Python Code: The preferred way of wrapping long lines is by using Python's implied line continuation inside parentheses, brackets and braces. Long lines …

  4. Python, next iteration of the loop over a loop - Stack Overflow

    Aug 4, 2016 · Python, next iteration of the loop over a loop Asked 15 years, 8 months ago Modified 9 years, 2 months ago Viewed 45k times

  5. python - Why does next raise a 'StopIteration', but 'for' do a …

    Why does next raise a 'StopIteration', but 'for' do a normal return? Asked 12 years, 9 months ago Modified 6 years, 5 months ago Viewed 186k times

  6. hasnext() for Python iterators? - Stack Overflow

    Python obviates this by throwing an exception at generator end. And the next(gen, default_value) idiom allows you to squelch that exception without needing try..except.

  7. python - Getting next element while cycling through a list - Stack …

    The idea is to access the next element while iterating. On reaching the penultimate element, you can access the last element. Use enumerate method to add index or counter to an iterable …

  8. How to access the previous/next element in a for loop?

    Is there a way to access a list 's (or tuple 's, or other iterable's) next or previous element while looping through it with a for loop? l = [1, 2, 3] for item in l: if item == 2: get_previous(l, item)

  9. Is it possible to break a long line to multiple lines in Python?

    In Python code, it is permissible to break before or after a binary operator, as long as the convention is consistent locally. For new code Knuth's style (line breaks before the operator) is …

  10. What does the "yield" keyword do in Python? - Stack Overflow

    Oct 24, 2008 · Yield in Python used to create a generator function. Generator function behaves like an iterator, which can be used in loop to retrieve items one at a time. When a generator …