def Resultat(x,y): diff = x-y return '%d:%02d' % divmod(diff, 60) Variation = Resultat( !ScePUPbr! , !SitPUPbr!)
def Resultat(x,y): diff = x-y if diff < 0: sign = '-' else: sign = '' return sign+'%d:%02d' % divmod(abs(diff), 60)
'-%d:%02d' % divmod(4, 60)
!Variation![0:1] + !testvari!
def Resultat(x,y): diff = abs(x-y) #abs doesn't make any difference without a positive and negative value if diff < 0: sign = '-' else: sign = '' #These are two single quotes (an empty string) return sign + '%d:%02d' % divmod(diff, 60)
def Resultat(x,y): diff = x-y if diff < 0: sign = '-' else: sign = '' #These are two single quotes (an empty string) return sign + '%d:%02d' % divmod(diff, 60)
ERROR 000539: Error running expression: Resultat( -2000 , 0) <type 'exceptions.TypeError'>: %d format: a number is required, not tuple
def Resultat(x,y): diff = x-y if diff < 0: sign = '-' else: sign = '' #These are two single quotes (an empty string) return '%s%d:%02d' % (sign, divmod(diff, 60))
Take the absolute value of the difference:diff = abs(x-y)
diff = abs(x-y)
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.