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...
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. http://docs.python.org/2.7/library/stdtypes.html#str.split And a walk thru the Tutorial in the help docs wouldn't hurt: http://docs.python.org/2.7/tutorial/index.html
bwCA, 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!
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.
Join our real-time social learning platform and learn together with your friends!