<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>&nbsp;&nbsp;&nbsp; mydic = {'A' : &quot;01000001&quot;, 'B' : &quot;01000010&quot;, 'C' : &quot;01000011&quot;}<br>&nbsp;&nbsp;&nbsp; strinput = 'ABBC'<br>&nbsp;&nbsp;&nbsp; result = [mydic[x] for x in strinput_process]<br>&nbsp;&nbsp;&nbsp; print result<br>&nbsp;</div>
<div>Cheers,</div>
<div>pujo<br><br>&nbsp;</div>
<div><span class="gmail_quote">On 9/24/05, <b class="gmail_sendername">Joseph Quigley</b> &lt;<a href="mailto:cpu.crazy@gmail.com">cpu.crazy@gmail.com</a>&gt; 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 &amp; 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 = &quot;01000001&quot;<br>B = &quot;01000010&quot;<br>C = &quot;01000011&quot;<br>D = &quot;01000100&quot;
<br>E = &quot;01000101&quot;<br>F = &quot;01000110&quot;<br>G = &quot;01000111&quot;<br>H = &quot;01001000&quot;<br>I = &quot;01001001&quot;<br>J = &quot;01001010&quot;<br>K = &quot;01001011&quot;<br>L = &quot;01001100&quot;
<br>M = &quot;01001101&quot;<br>N = &quot;01001110&quot;<br>O = &quot;01001111&quot;<br>P = &quot;01010000&quot;<br>Q = &quot;01010001&quot;<br>R = &quot;01010010&quot;<br>S = &quot;01010011&quot;<br>T = &quot;01010100&quot;
<br>U = &quot;01010101&quot;<br>V = &quot;01010110&quot;<br>W = &quot;01010111&quot;<br>X = &quot;01011000&quot;<br>Y = &quot;01011001&quot;<br>Z = &quot;01011010&quot;<br><br># Symbols<br>exclamationPoint = &quot;0010 0001&quot;
<br>hash = &quot;0010 0011&quot;<br>dollar = &quot;001 0100&quot;<br>percent = &quot;0010 0101&quot;<br>_and = &quot;0010 0110&quot;<br>parentheses = &quot;0010 1000&quot;<br>closeParentheses = &quot;0010 1001&quot;<br>comma = &quot;0010 1100&quot;
<br>dash = &quot;0010 1101&quot;<br>period = &quot;0010 1110&quot;<br>underline = &quot;0101 1111&quot;<br><br># Numbers<br>zero = &quot;00110000&quot;<br>one = &quot;00110001&quot;<br>two = &quot;00110010&quot;<br>three = &quot;00110011&quot;
<br>four = &quot;00110100&quot;<br>five = &quot;00110101&quot;<br>six = &quot;00110110&quot;<br>seven = &quot;00110111&quot;<br>eight = &quot;00111000&quot;<br>nine = &quot;00111001&quot;<br><br>ltra = &quot;a&quot;<br>ltrb = &quot;b&quot;
<br>ltrc = &quot;c&quot;<br>while True:<br>&nbsp;&nbsp; text = raw_input(&quot;Enter text: &quot;)<br>&nbsp;&nbsp; text = list(text)<br><br>Thanks,<br>&nbsp;&nbsp; Joe<br><br>_______________________________________________<br>Tutor maillist&nbsp;&nbsp;-&nbsp;&nbsp;<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>