Creation and use of ranges in Python

Loops created with “for”  necessarily need to have ranges. First write for, then the variable this loop is applying like x, after this goes in range, and in parenthesis the number it will stop, and it will start from 0 (8), another option is to separate with a comma the number you want to start and the number you want it to stop, (0,-8), the last way of using the range is first the numer it is going to start, then separated with a comma the number it is going to end, and sepparated from another comma the number of numbers it will count per time. For example: for i in range (1,sz+1):

 

 

CC BY 4.0 Creation and use of ranges in Python by Jorge Padilla is licensed under a Creative Commons Attribution 4.0 International License.

Comments are closed.