HelloI wrote a function named vertical to print string .printable characters and ASCII values in a table. 1)It is swallowing some characters. 2)It output some characters 2 or 3 times. 3)It prints one column more than what I asked for.
It may be a division problem(floating point). Its sibling called horizontal got no problems. please examine it and give suggestions and improvements to set it right. #!usr\\bin\\env python def horizontal(columns): import string n=0 v=string.printable v=v.replace('\n','') v=v.replace('\t','') while n<len(v): try: for x in range (n,n+columns,1): print '%s'%v[x],'=','%3d'%ord(v[x]),' '*3, print n+=columns except IndexError:break def vertical(columns): import string v=string.printable v=v.replace('\n','') v=v.replace('\t','') for x in range((len(v))/columns): for y in range(x,len(v),x+((len(v))/columns)): print v[y],'=',ord(v[y]),' '*3, print Thanks in advance. Prasad.
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor