[Python] Help with for loop output
I've been trying to build a piece of code to duplicate the characters in a string, and save them to new string (so for 'cat' I would get 'ccaatt'). I've been running the code below (note the (tab) indicates a Tab indent as I'm not sure how to format reddit over mobile):
for c in z:
My output is: 'cattt'
Shifting the [p:p+1] to [p-1:p] ouputs: 'cataa'
Any idea what I'm doing wrong?
Submitted July 13, 2017 at 01:29PM by 123zxcfgh
via reddit http://ift.tt/2unAnRq