""" Authors: Peter Mawhorter Consulted: Date: 2023-10-9 Purpose: Lab 6 loop debugging solutions. """ # Initial code for sumUpTo def sumUpTo(top): """ Returns the sum of all numbers from 1 up to and including top. """ result = 0 for n in range(top): result += n return result # Version with print added def sumUpTo(top): """ Returns the sum of all numbers from 1 up to and including top. """ result = 0 for n in range(top): print("n:", n) result += n return result # Version with return bug fixed def sumUpTo(top): """ Returns the sum of all numbers from 1 up to and including top. """ result = 0 for n in range(top): print("n:", n) result += n return result # Version with both bugs fixed def sumUpTo(top): """ Returns the sum of all numbers from 1 up to and including top. """ result = 0 for n in range(1, top + 1): print("n:", n) result += n return result