Python Forum
Move a character left or right in a file.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Move a character left or right in a file.
#2
Sorry, deleted the other post.

You're not taking into account the length of the string. That is, pos only tells you how wide the left side should be, and you are setting both the left and the right side based on that. So the further left you move, the shorter the string gets, and the further right you move the longer the string gets.

I would fill in the right side by adding 0's until len(new) == len(line) - 1, and then adding a 1.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
RE: Move a character left or right in a file. - by ichabod801 - Mar-21-2019, 06:21 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Writing string to file results in one character per line RB76SFJPsJJDu3bMnwYM 4 1,521 Sep-27-2022, 01:38 PM
Last Post: buran
  PyQT5 - align left frohr 7 4,224 May-07-2022, 09:56 PM
Last Post: deanhystad
  How did one column get left-justified? Mark17 6 2,063 Feb-26-2022, 11:55 PM
Last Post: deanhystad
  [solved] unexpected character after line continuation character paul18fr 4 3,614 Jun-22-2021, 03:22 PM
Last Post: deanhystad
  Move file from one folder to another folder with timestamp added end of file shantanu97 0 2,564 Mar-22-2021, 10:59 AM
Last Post: shantanu97
  Explanation of the left side of this statement please rascalsailor 3 2,601 Sep-09-2020, 02:02 PM
Last Post: rascalsailor
  SyntaxError: unexpected character after line continuation character siteshkumar 2 3,282 Jul-13-2020, 07:05 PM
Last Post: snippsat
  How to left align logging messages Mekala 3 7,047 Jun-28-2020, 04:04 PM
Last Post: bowlofred
  Shutil move if file exists in destination Friend 2 6,942 Feb-02-2020, 01:45 PM
Last Post: Friend
  how can i handle "expected a character " type error , when I input no character vivekagrey 2 2,826 Jan-05-2020, 11:50 AM
Last Post: vivekagrey

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020