Trying to understand nested loops

Weatherby,Gerard gweatherby at uchc.edu
Fri Aug 5 09:13:09 EDT 2022


It’s also a poor code example. Doing a pointless double loop is not good instructional practice, especially when simpler alternatives exist. e.g.

for i in range(3):
    for j in range(-2.-7,-2):
print(i +j )


—
Gerard Weatherby | Application Architect NMRbox | NAN | Department of Molecular Biology and Biophysics
 UConn Health 263 Farmington Avenue, Farmington, CT 06030-6406 uchc.edu
On Aug 5, 2022, 4:38 AM -0400, ojomooluwatolami675 at gmail.com <ojomooluwatolami675 at gmail.com>, wrote:

var = 0
for i in range(3):
for j in range(-2,-7,-2):
var += 1
print(var)


More information about the Python-list mailing list