Swap two number

i just need to swap to number
i try it on REPL and some thing weird is happen

function highestValuePalindrome(s, n, k)
temp = Array{Int64}(undef,n)
j=1
for i in s
println(i) # here i =3
  temp[j] = i # i is 3 right ?  why he put the number 51 ? 
  j+=1
  println(temp)
end

end
s =  "3493"
k=1
n=4
println("Total pairs   " ,highestValuePalindrome(s, n, k))

the final output is [51, 52, 57, 51]
what is this number ?

s is a String. If you iterate s, as you are doing, you get characters. The numbers you see are the code of the characters in the encoding it is being used.

julia> for c in "3493"; println(Int(c)); end
51
52
57
51

Instead of attributing the character to the Vector{Int64} directly, you should use parse.

julia> for c in "3493"; println(parse(Int, c)); end
3
4
9
3
3 Likes