Why cant I enter in to the for loop for the below code
def maximumSwap(num):
A = map(int, str(num))
last = {x: i for i, x in enumerate(A)}
for i, x in enumerate(A):
print(i, x)
for d in range(9, x, -1):
if last.get(d, None) > i:
A[i], A[last[d]] = A[last[d]], A[i]
return int("".join(map(str, A)))
return num
I was able to print the last but not able to enter the for loop. And I also want to know what is the difference between int(num)
and map(int, str(num))