# Swap two number

**URL:** https://discourse.julialang.org/t/swap-two-number/44456
**Category:** New to Julia
**Created:** [August 6, 2020, 8:49pm UTC](https://discourse.julialang.org/t/swap-two-number/44456 "2020-08-06T20:49:05Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Fuad\_Sami](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fuad_sami/32/16900_2.png) [@Fuad\_Sami](https://discourse.julialang.org/u/Fuad_Sami)
#### Post date: [August 6, 2020, 8:49pm UTC](https://discourse.julialang.org/t/swap-two-number/44456/1 "2020-08-06T20:49:05Z")

</div>

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

```julia
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 ?

---

<div class="post-metadata">

### Author: ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)
#### Post date: [August 6, 2020, 9:24pm UTC](https://discourse.julialang.org/t/swap-two-number/44456/2 "2020-08-06T21:24:47Z")

</div>

`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
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
julia> for c in "3493"; println(parse(Int, c)); end
3
4
9
3

```
