#NEWLINE# def vat_number_check_digit( vat_number ) : #NEWLINE# #INDENT# 'Calculate Italian VAT number check digit.' #NEWLINE# normalized_vat_number = smart_text ( vat_number ) . zfill ( 10 ) #NEWLINE# total = 0 #NEWLINE# for i in range ( 0 , 10 , 2 ) : #NEWLINE# #INDENT# total += int ( normalized_vat_number [ i ] ) #NEWLINE# #UNINDENT# for i in range ( 1 , 11 , 2 ) : #NEWLINE# #INDENT# ( quotient , remainder ) = divmod ( ( int ( normalized_vat_number [ i ] ) * 2 ) , 10 ) #NEWLINE# total += ( quotient + remainder ) #NEWLINE# #UNINDENT# return smart_text ( ( ( 10 - ( total % 10 ) ) % 10 ) )