I'm a new programmer learning python and am having trouble with how to approach this task:
So essentially I have a string of numbers to read imported from a file, and need to add the sum of the first number to the second and convert it to the correct ascii character. So, for example if I am reading the string:
'36 30 25 40 80 4'
Another method that is less opaque (though more verbose) than Patrick's proposal would be:
>>> x = '36 30 25 40 80 4' >>> nums = [int(n) for n in x.split()] >>> ''.join(chr(sum(nums[i:i+2])) for i in range(0, len(nums), 2)) 'BAT'