请问这应该怎么写哇?求解答

img

s=input()
n=0
l=[]
for i in s:
    if (i>='0' and i<='9') or (i.lower()>='a' and i.lower()<='f'):
        print(i,end='')
        l.insert(0,i)
print()
j=0
for i in l:
    if i>='0' and i<='9':
        n+=int(i)*pow(16,j)
    if i.lower()>='a' and i.lower()<='f':
        n+=(ord(i.lower())-87)*pow(16,j)
    j+=1
print(n)

觉得有用的话采纳一下哈