# squareEach-6.11.py # Square the numbers in a list by modifying the list parameter. # Neal Nelson 2007.10.30 # This function modifies the list argument passed in def squareEach(nums): # nums coming in looks like [4,6,8] # modify nums to look like [16, 36, 64] for i in range(len(nums)): nums[i] = nums[i] ** 2 def main(): nums = input("Enter a list of numbers with brackets, eg, [4,6,8] :") print nums # should print eg [4,6,8] squareEach(nums) # list nums has been modified as a side effect of the squareEach function print "Squaring this list gives:", nums print nums # prints eg [16, 36, 64] showing nums parameter modified main()