The input consists of a series of lines each containing one command. Any extra spaces at the start and end of each line should be discarded. Blank lines are ignored. Any line which starts with a # (after stripping any leading spaces) is a comment, and is discarded.
The instructions operate on a single line, which they can modify or print. The output is the sequence of prints. The line is initially empty. Operations are performed at a current position within the line. The current position is always at the start or end of the line, or between two characters. It is at the front of the line initially. Each instruction starts with an optional numeric repeat count which defaults to one. The repeat count simply causes the command to be executed that many times. The parts of each command are separated by spaces. Here are the commands.
Insert the indicated non-blank string into the current line following the current position. Any characters following the insertion move over to make room. The position is left at the end of the insertion.
Insert a space (or n spaces) at the current point leaving the point after the insertion.
Cut the next n characters from the current line and copy it into a clipboard. Any existing clipboard contents is replaced. Note: because we replace the existing clipboard for each cut command, running n cut is different from the cut command n times.
Insert the contents of the clipboard into the current line following the current position. The position is moved to the end of the insertion. The clipboard does not change.
Move the current location (n times) to the right. If this moves past the end of the line, the line is extended with spaces.
Move the current location to the left. If the move goes past the front of the string, stop at the front.
Move the current location to the start of the current string.
Move the current location to the end of the current string.
Print the current line. Neither the contents of the line, the clipboard, nor the current position changes.
Empty the current line and set the position at the start. The clipboard does not change.
For the input:
When your program works, submit over the web here.
![]() |
Python Assignment 3![]() |