Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 20 Online
OpenStudy (anonymous):

Hi, I needed help on programming exercise number 1, in chapter 4 of the book Python programming 'Introduction to computer science' by John Zelle, 2nd edition (the recommended book for this course)...if anyone can help me please let me know, Thanks.

OpenStudy (anonymous):

can you state the problem - for those of us that do not have the book?

OpenStudy (anonymous):

yes, I can. Here it is: Please see the following prgram: # This program converts a sequence of ASCII numbers into a string of text. import string def main(): inString = raw_input ( "Enter the SCII-encoded message: ") message = "" for numStr in string.split(inString): asciiNum = eval (numStr) message = message + chr (asciiNum) print "The encoded message is: ", message main() Now, the question is asking to re-write the code above using a list. It says that the message can be accumulated as a list of characters where each new character is appended to the end of the existing list. The message can then be formed by joining the characters in the list, using an empty string between the characters. (see below) string.join (msgList," ") It says, use this approach to redo the program above. Thanks for your help in advance.

OpenStudy (anonymous):

take an empty list instead of an empty string and append asciiNum to it. Finally use string.join (msgList," ")

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!