There is no evidence that's true. People still take drugs in countries with the death penalty.
Of course, some people are so selfish and impulsive not much will deter them, but at least they're off the streets where they can make life miserable for the rest of us.