Python has a very simple way to convert text to ASCII and ASCII to text. To find the ASCII value of a character use the ord() function. Example: >>> ord('B') 66 To get a character from it's ASCII value use the chr() function. Example: >>> chr(65) 'A' Here is a program to get the list of all characters along with their values: # program to print the list of characters and their ASCII values for value in range(0, 255): print "ASCII Value:", value, "\t", "Character:", chr(value), "\n" Here is another simple ASCII encoding-decoding program: # Convertion from text to ASCII codes message = raw_input("Enter message to encode: ") print "Decoded string (in ASCII):" for ch in message: print ord(ch), print "\n\n" # Convertion from ASCII codes to text message = raw_input("Enter ASCII codes: ") decodedMessage = "" for item in message.split(): decodedMessage += chr
Comments
import sys
for line in sys.stdin:
# do whatever you want with line
Note that there is an extra newline character ("\n") after end of each line.
SAMPLE INPUT
3
1 1 1
3 5 6
2 1 2
how to take this input??
while t:
t = t - 1
s = raw_input()
n, a, d = s.split()
n = int(n)
a = int(a)
d = int (d)
n, a, d = [int(x) for x in raw_input().split()]
while t:
....t = t - 1
....s = raw_input()
....n, a, d = s.split()
N, A, D = map(int, raw_input().split())