Python Forum

Full Version: Look over this code
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey guys would anyone be able to look over this for a buddy of mine and see why this is not working. I’m not familiar with really any python.

From what I understand they have an account who has to write 80 paragraphs for their thing and then need a break. Whenever they enter it it gets rid of the paragraphs. So he had the idea to come up with this to fix that problem.

This might be super simple,

Thank you very much!

def insert_line_breaks():

    editor.beginUndoAction()

    pos = 80

    while pos < editor.getTextLength():

        editor.insertText(pos, '\n')

        pos += 81  # Move to the next position after the newly inserted line break

    editor.endUndoAction()

 

insert_line_breaks()
Hey guys would anyone be able to look over this for a buddy of mine and see why this is not working. I’m not familiar with really any python.

From what I understand they have an account who has to write 80 paragraphs for their thing and then need a break. Whenever they enter it it gets rid of the paragraphs. So he had the idea to come up with this to fix that problem.

This might be super simple,

Thank you very much!

def insert_line_breaks():

    editor.beginUndoAction()

    pos = 80

    while pos < editor.getTextLength():

        editor.insertText(pos, '\n')

        pos += 81  # Move to the next position after the newly inserted line break

    editor.endUndoAction()

 

insert_line_breaks()
It happens like that on my pc or online editor. Or blogging. Sometimes. But a whole paragraph or 80 paragraphs? Any idea what this function will look like?