I think that my logic is correct but I am getting initial value as print, why?

What is the reverse complement of GCTAGCT?

function pattern_RC(dna)
R_dna = “”
ln = length(dna)
for i in ln:-1:1
if dna[i] == “A”
R_dna = R_dna * “T”
elseif dna[i]== “T”
R_dna = R_dna * “A”
elseif dna[i]== “G”
R_dna = R_dna * “C”
elseif dna[i]== “C”
R_dna = R_dna * “G”
else
#println(“Error in the code”)
end
end
return R_dna
end
dna= “GCTAGCT”
R_dna = pattern_RC(dna)
println("Reverse Complement of DNA strand is : ", R_dna)

I am sorry for simple stupid question. But I am trying to learn Julia by doing.

I tried to run it with println statments to check, it seems to me that I have error in if… elseif conditions.
Please help me.

In Julia “A” is not ‘A’

'A'=="A"

yields false. So simply replace all " " with ’ ’ and is should work.

2 Likes

wow, thanks for quick answer.
Its always great help for newbie.
:pray: