Files
codeql/python/ql/src/Statements/NestedLoopsSameVariableWithReuse.py
2018-11-19 15:10:42 +00:00

17 lines
453 B
Python

def largest_elements(l):
for x in l:
maxnum = 0
for x in x:
maxnum = max(x, maxnum)
# The outer loop variable x has now been overwritten by the inner loop.
print "The largest element in the list", x, "is", maxnum
def largest_elements_correct(l):
for x in l:
maxnum = 0
for y in x:
maxnum = max(y, maxnum)
print "The largest element in the list", x, "is", maxnum