I am working slowly through this course, doing both the assignments and the "finger exercises" in the book. I am now on finger exercise 3.2, which gives a string of numbers separated by commas, and asks they be added togther. The book demonstrates how to do this with a string not separated by commas. The lectures have shown how to do it with a list. A string separated by commas is something I have not seen an example of. Did I miss it? Is the expectation to Google it? I don't mind doing that, I'm just wondering whether I missed something...
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga.
Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.
Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
BTW, sorry for the double post (I put it in Comp Sci, not realizing there is a separate space for the MIT 6.00). It's a wonder I can tie my shoes let alone program, but I struggle through.
i would think that you have to put those strings into a data structure. either a list, or a tuple or a dictionary or a set. a sequence data type most likely.
perhaps the split() string method might help.
And a walk thru the Tutorial in the help docs wouldn't hurt:
Thanks. I did wind up using .split on the string to generate an equivalent list of floats.
It just seemed the data could have been provided in list form to begin with as easily as string form, so converting from string to list seemed like possibly missing the point. Especially since I don't recall the professor or TA talking about such conversions.
But that is what I did and it worked. Thanks!
Not the answer you are looking for? Search for more explanations.
The purpose of the course is not to teach you the Python programming language - it is to teach you computer science and programming methods. They expect you to avail yourself to the wealth of help and documentation available for the language itself.