Chewbacca and Number Question

Please give an explanation how the test case is being inverted to give the output. Not able to understand to solve the question.

approach is simple
read a number as string (say s) .
if left most character is ‘9’

then leave the leftmost character as it is and for other characters simpl replace s[i] with min(s[i],‘9’-s[i])
else:

for each i replace s[i] with min(s[i],‘9’-s[i])
print s

Here is the code :- https://ide.codingblocks.com/s/411768, but giving error for the min function. Please tell the error and how to resolve it.

Note:

A. To Convert a Given Character Value to the Corresponding Integer Value:

Subtract '0'.

Example: '2' - '0' = (int) 2

B. To Convert a Given Integer Value to the Corresponding Character:

Add '0'.

Example: 2 + '0' = 50 {ASCII Value for '2'} 

see this:https://ide.codingblocks.com/s/412118

also for 99
output should be 90
Try to debug with this