Here is the basic code for inverting a number:
answer = ''
x=input()
for i in range(len(x)):
digit = 9 - int(x[i])
answer = answer + str(digit)
print(answer)
You may need to modify that to take account of any other rules you are supposed to follow. By the way the line
1 <= int(x) <= 10^18
does not actually do anything. It is a good idea to test your code as you write it, and try and fix any errors immediately as you see them.