Question: Write a shell (text-based) program, called sum_all.py, opens a text file called stuff.txt with 1 number per line and prints out the sum of all

Write a shell (text-based) program, called sum_all.py, opens a text file called stuff.txt with 1 number per line and prints out the sum of all the numbers (no matter how long the file is). For example, if stuff.txt has the following lines: 100 300 200 please help thank you!

f = open("stuff.txt")

big_str = f.read()

line_list = big_str.split(" ")

for i in range(1, len(line_list)):

print("sum is " + str(x))

I got lost please help.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!