Say that you have a file and the list of numbers like

10 20 16 17 82 93 87

How could I add/subtract/ or multiply these individually?

Recommended Answers

All 2 Replies

for line in open("file"):
    nums = [int(x) for x in line.split()]
    # nums now contains a list of integer
    # you can add/subtract/multiply by traversing the list

edit: new topic

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.