About 87,800 results
Open links in new tab
  1. How does the Python's range function work? - Stack Overflow

    [Update: for Python3 (the currently maintained versions of Python) the range() function always returns the dynamic, "lazy evaluation" iterator; the older versions of Python (2.x) which …

  2. python - Why does range(start, end) not include end ... - Stack …

    It's also useful for splitting ranges; range(a,b) can be split into range(a, x) and range(x, b), whereas with inclusive range you would write either x-1 or x+1. While you rarely need to split …

  3. python - How can I access the index value in a 'for' loop? - Stack …

    Notice that the index runs from 0. This kind of indexing is common among modern programming languages including Python and C. If you want your loop to span a part of the list, you can use …

  4. python - range () for floats - Stack Overflow

    Dec 6, 2015 · Is there a range() equivalent for floats in Python? >>> range(0.5,5,1.5) [0, 1, 2, 3, 4] >>>; range(0.5,5,0.5) Traceback (most recent call last): File "<pyshell#10 ...

  5. Iterating through a range of dates in Python - Stack Overflow

    Jun 30, 2009 · Why are there two nested iterations? For me it produces the same list of data with only one iteration: for single_date in (start_date + timedelta(n) for n in range(day_count)): print ...

  6. python - Using in range(..) in an if-else statment - Stack Overflow

    Aug 27, 2012 · python 2.7. Is it possible to do this: print "Enter a number between 1 and 10:" number = raw_input("> ") if number in range(1, 5): print "You entered a number in the range of …

  7. python - How to make for loop without iterator variable ... - Stack ...

    @blackkettle: it's faster because it doesn't need to return the current iteration index, which is a measurable part of the cost of xrange (and Python 3's range, which gives an iterator, not a …

  8. python - How do I use a decimal step value for range ... - Stack …

    How do I iterate between 0 and 1 by a step of 0.1? This says that the step argument cannot be zero: for i in range(0, 1, 0.1): print(i)

  9. string - Python: how to print range a-z? - Stack Overflow

    The fact that I can type does not mean that I can "python", I really like gnibbler's answer over for-messy-things. Thanks everyone for your answers and -- keep things simple, special thanks to …

  10. python - Print a list in reverse order with range ... - Stack Overflow

    Sep 2, 2011 · $ python -m timeit "range(9,-1,-1)" 1000000 loops, best of 3: 0.401 usec per loop The last option is easy to remember using the range(n-1,-1,-1) notation by Val Neekman . [1] …

Refresh