File's Data keeps getting overwritten by function
<p>for some reason I am running into an issue where my function call seems to be overwriting the data read in from the file without me asking it to. I am trying to get the sum of the original list but I keep getting the sum of the squared list. </p>

<p><strong>CODE:</strong></p>

<pre><code>def toNumbers(strList):
    for i in range(len(strList)):
        strList[i] = strList [int(i)]
    return strList


def squareEach(nums):
    for i in range(len(nums)):
        nums[i] = eval(nums[i])
        nums[i] = nums[i]**2
    return nums




def sumList(nums):
    b = sum(nums)
    return b





def main():
    file=open("numbers.txt","r").readline().split(" ")
    print(str(squareEach(file)))
    print(str(sumList(file)))
</code></pre>

<p>The list <code>nums</code> is modified in <code>squareEach</code> method. Consider storing the results in a different list variable of the below sort:</p>

<pre><code>def squareEach(nums):
    sq = list()
    for i in range(len(nums)):
        sq.append(str(int(nums[i])**2))
        # nums[i] = str(int(nums[i])**2)
    return sq
</code></pre>

python file-io