python - Converting range of numbers with respective ASCII codes -
how convert set of values characters
every number in range should converted , returned
without using control statements , loops
eg: range(97,100) should converted {'a','b','c'}
try this:
>>> map(chr, range(97,100)) ['a', 'b', 'c']
use of char:
>>> chr(97) 'a'
using list comprehension:
>>> [chr(x) x in range(97,100)] ['a', 'b', 'c']
to in unicode use unichr
:
>>> [unichr(x) x in range(97,100)] [u'a', u'b', u'c']
Comments
Post a Comment