python - How to edit string letters in a for loop -
i'm new python , cannot find way this.
i want change letters of string based on criteria. here code:
for c in text: ordchar=ord(c) if ordchar>=65 , ordchar<=90: ordchar=ordchar+13 if ordchar>90: ordchar=ordchar-90+64 c=chr(ordchar) else: if ordchar>=97 , ordchar<=122: ordchar=ordchar+13 if ordchar>122: ordchar=ordchar-122+96 c=chr(ordchar) return text the returned text value same parameter value. thought variables pointers, editing c, should edit text. doing wrong?
you're not "editing" c, you're assigning else. 1 alternative build new string instead of trying mutate old 1 (which impossible), instead of c=... have newstr += ....
Comments
Post a Comment