I am new to robot framework and trying to implement Luhn Algorithm.
I found the code in python and want to change it to Robot framework.
def cardLuhnChecksumIsValid(card_number):
""" checks to make sure that the card passes a luhn mod-10 checksum """
sum = 0
num_digits = len(card_number)
oddeven = num_digits & 1
for count in range(0, num_digits):
digit = int(card_number[count])
if not (( count & 1 ) ^ oddeven ):
digit = digit * 2
if digit > 9:
digit = digit - 9
sum = sum + digit
return ( (sum % 10) == 0 )
I started with robotscript and was stuck at statement if not (( count & 1 ) ^ oddeven ) can someone please help me convert the above code to robot script
is there a automated to change python code to robot ?
cardLuhnChecksumIsValid
[Arguments] ${ICCID1}
${num_digits} Get length ${ICCID1}
${odd_even} ${num_digits}
... AND ${1}
FOR ${Count} IN RANGE 0 ${num_digits}
${digit} Convert To Integer ${ICCID[${Count}]}
question from:
https://stackoverflow.com/questions/65881409/luhn-algorithm-robot-framework 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…