python - string concatenation appends to beginning instead of the end -


i need check if last char of line / if not add one. i'm able go through ident process if last character / when concatenate / string, appears @ beginning of line , not @ end. can't find hint why it's happening. have code:

for x in file:     x= x.rstrip('\n') #deleting cr @ eol     xx=len(x)     if x[xx-2:xx-1] != ("/"):         x=x[:xx]+"/" # nor 1 working x=x+"/" 

this adds / beginning of file.

getting same thing in peace url = add+x+page+yas, have page added @ beginning

assuming want add path separator ('/' on unix):

for x in file:     x = os.path.join(x.rstrip(), '') 

and of course you'll have add import os or from os import path @ start of code.


Comments