Hex Addition function
Posted in Uncategorized by Julian Kessel - May 02, 2010
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | def add_hex(arr): result = 0x0 index = 0 while True: print index try: result = result + int(arr[index], 16) + int(arr[index+1], 16) except IndexError: try: result = result + int(arr[index], 16) except IndexError: pass result = hex(result) break index+=2 return result print add_hex2(['0x01', '0x05', '0x04', '0x09', '0x17']) |

