Pujo Aji wrote:
> If your symbol are specific it is better to use dictionary.
> then if the user give an input you can take character by character and 
> translate into your binary.
> This is the code textTobinary:
>     mydic = {'A' : "01000001", 'B' : "01000010", 'C' : "01000011"}
>     strinput = 'ABBC'
>     result = [mydic[x] for x in strinput_process]
>     print result
>  

You might also want to look at "Number to String in Arbirtrary Base" recipe:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/365468

It uses a more innovative approach.

--
Poor Yorick

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to