"""Python script to turn ascii text into binary type `python text-to-bin.py' from the command line, in the correct directory, to start the program. Type whatever you want, and then press `Ctrl+d' to quit. This will fail hard if you try to convert anything that's not in the `binary_code_for' dictionary, because error-detecting code is hellishly ugly. Also, the uppercase numbers are incorrect.""" from sys import stdin binary_code_for = { 'a' : '01100001', 'b' : '01100010', 'c' : '01100011', 'd' : '01100100', 'e' : '01100101', 'f' : '01100110', 'g' : '01100111', 'h' : '01101000', 'i' : '01101001', 'j' : '01101010', 'k' : '01101011', 'l' : '01101100', 'm' : '01101101', 'n' : '01101110', 'o' : '01101111', 'p' : '01110000', 'q' : '01110001', 'r' : '01110010', 's' : '01110011', 't' : '01110100', 'u' : '01110101', 'v' : '01110110', 'w' : '01110111', 'x' : '01111000', 'y' : '01111001', 'z' : '01111010', 'A' : '01111011', 'B' : '01111100', 'C' : '01111101', 'D' : '01111110', 'E' : '01111111', 'F' : '10000000', 'G' : '10000001', 'H' : '10000010', 'I' : '10000011', 'J' : '10000100', 'K' : '10000101', 'L' : '10000110', 'M' : '10000111', 'N' : '10001000', 'O' : '10001001', 'P' : '10001010', 'Q' : '10001011', 'R' : '10001100', 'S' : '10001101', 'T' : '10001110', 'U' : '10001111', 'V' : '10010000', 'W' : '10010001', 'X' : '10010010', 'Y' : '10010011', 'Z' : '10010100', ' ' : '00010010', '\n': '00000100' } for each_sentence in stdin: for each_letter in each_sentence: print binary_code_for[each_letter],