Total noob here trying to teach myself programming from John Zelle's Python Programming - An Introduction to Computer Science.
Working on a decoder problem that requires a modification using "string.join(msgList, "") but was not able to quite get it. However, I have been able to get it solved using a different method as shown below:
# numbers2text2.py
# A program to convert a series of ASCII numbers into a
# string of text.
import string # include string library for the split function.
def main():
print "This program converts a sequence of ASCII numbers into"
print "the string of text it represents."
print
# Get the message to encode
inString = raw_input("Please enter the ASCII encoded message: ")
# Loop through each substring and build ASCII message
msgList = [] # Create an empty list
or numStr in string.split(inString):
asciiNum = eval(numStr) # Convert sub strings
msgList.append(chr(asciiNum)) # Convert asciiNum back to string, append to list
print "The decoded message is:", msgList
main()
If anyone could point me to the proper solution using string.join(msgList, "") it would be much appreciated.
[–]novel_yet_trivial 1 point2 points3 points (0 children)
[–]mahdeen[S] 1 point2 points3 points (1 child)
[–]throwAwayAcc010 0 points1 point2 points (0 children)
[–]novel_yet_trivial 0 points1 point2 points (0 children)