On 09/12/2012 07:20 AM, Aaron Pilgrim wrote: > Hello, > I am trying to write a small program that converts ascii to binary. > > I tried using the python reference library section 18.8 but had > trouble understanding how to make it work.
If you supplied a link, we might be able to figure out what section 10.8 is. It'll vary between versions of Python. And in version 2.7, there doesn't seem to be a section 10.8 http://docs.python.org/reference/index.html#reference-index It would also be useful to specify the version of Python that this is for. But on the assumption that it's either 2.6 or 2.7, try the following link: http://docs.python.org/library/functions.html#bin if that's not what you want, then you'd better give us some sample input and output, or give the usage context or quote the assigmment. > Here is the code I am currently trying to use: > > def main(): > import binascii > myWord = input("Enter the word to convert..") > #convert text to ascii > for ch in myWord: > print(ord(ch)) > #convert ascii to binary > binascii.a2b_uu(ord(ch)) That function converts a line of uuencoded data to the binary data that generated it. Your ch isn't a line of uuencoded data, and you don't do anything with the return value. Besides, your subject line implies you want the reverse order. > main() > > -- DaveA _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor