The way I implemented this strategy was to make sure I had a single cigarette and lighter on me at all times. I named the cigarette, which psychologically helped prevent me from smoking it. I stuck that out for a few months until a friend smoked it in desperation. At that point I felt confident I’d quit because I wanted to, not because of random circumstance.
The official Python tutorial is very well written and is suitable for total beginners:
https://docs.python.org/3/tutorial/