"that the L-rd your G-d gives to you": in your merit.
"you shall not learn to do as the abominations of those nations": I might think that you are forbidden to understand and teach (the falsity of their ways); it is, therefore, written "to do." You may not learn them to do them, but you may learn them to each and to understand.
(Devarim 18:10) "There shall not be found among you": Beth-din is being exhorted to this end.