[Tutor] Program xy.py

Mats Wichmann mats at wichmann.us
Fri Dec 22 14:21:42 EST 2023


On 12/22/23 04:49, Ethan Rosenberg wrote:
> Thank you for the excellent help you give to python programmers.
> 
> This program should put i*j  in a 2x2 matrix.

>      for j in range(0,1):

 From the Python interpreter itself:

 >>> help(range)
Help on class range in module builtins:

class range(object)
  |  range(stop) -> range object
  |  range(start, stop[, step]) -> range object
  |
  |  Return an object that produces a sequence of integers from start 
(inclusive)
  |  to stop (exclusive) by step.


Notice it doesn't include the stop value, so if you think you're getting 
an iterator that produces two values from range(0, 1) - you won't. 
You'd need range(0, 2) for that.




More information about the Tutor mailing list