<div>If your symbol are specific it is better to use dictionary.</div>
<div>then if the user give an input you can take character by character and translate into your binary.</div>
<div>This is the code textTobinary:</div>
<div> mydic = {'A' : "01000001", 'B' : "01000010", 'C' : "01000011"}<br> strinput = 'ABBC'<br> result = [mydic[x] for x in strinput_process]<br> print result<br> </div>
<div>Cheers,</div>
<div>pujo<br><br> </div>
<div><span class="gmail_quote">On 9/24/05, <b class="gmail_sendername">Joseph Quigley</b> <<a href="mailto:cpu.crazy@gmail.com">cpu.crazy@gmail.com</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Hi I'm playing with a Binary to text & text to binary converter. I can't<br>figure out how to replace the characters (first stage: text to binary).
<br><br>I thought lists would be the best but I really don't know how to use<br>them... here's my code:<br>#! /usr/bin/env python<br>A = "01000001"<br>B = "01000010"<br>C = "01000011"<br>D = "01000100"
<br>E = "01000101"<br>F = "01000110"<br>G = "01000111"<br>H = "01001000"<br>I = "01001001"<br>J = "01001010"<br>K = "01001011"<br>L = "01001100"
<br>M = "01001101"<br>N = "01001110"<br>O = "01001111"<br>P = "01010000"<br>Q = "01010001"<br>R = "01010010"<br>S = "01010011"<br>T = "01010100"
<br>U = "01010101"<br>V = "01010110"<br>W = "01010111"<br>X = "01011000"<br>Y = "01011001"<br>Z = "01011010"<br><br># Symbols<br>exclamationPoint = "0010 0001"
<br>hash = "0010 0011"<br>dollar = "001 0100"<br>percent = "0010 0101"<br>_and = "0010 0110"<br>parentheses = "0010 1000"<br>closeParentheses = "0010 1001"<br>comma = "0010 1100"
<br>dash = "0010 1101"<br>period = "0010 1110"<br>underline = "0101 1111"<br><br># Numbers<br>zero = "00110000"<br>one = "00110001"<br>two = "00110010"<br>three = "00110011"
<br>four = "00110100"<br>five = "00110101"<br>six = "00110110"<br>seven = "00110111"<br>eight = "00111000"<br>nine = "00111001"<br><br>ltra = "a"<br>ltrb = "b"
<br>ltrc = "c"<br>while True:<br> text = raw_input("Enter text: ")<br> text = list(text)<br><br>Thanks,<br> Joe<br><br>_______________________________________________<br>Tutor maillist - <a href="mailto:Tutor@python.org">
Tutor@python.org</a><br><a href="http://mail.python.org/mailman/listinfo/tutor">http://mail.python.org/mailman/listinfo/tutor</a><br></blockquote></div><br>