Search Results

Search found 1 results on 1 pages for 'user1919840'.

Page 1/1 | 1 

  • wrap all lines that are longer than line length

    - by user1919840
    I am writing a program that limits each line to a certain length. this is what i got so far, i am almost done but i still need to cut each line, but i cant figure it out. def main(): filename = input("Please enter the name of the file to be used: ") openFile = open(filename, 'r+') file = openFile.read() lLength = int(input("enter a number between 10 & 20: ")) while (lLength < 10) or (lLength > 20) : print("Invalid input, please try again...") lLength = int(input("enter a number between 10 & 20: ")) wr = textwrap.TextWrapper() wraped = wr.wrap(file) print("Here is your output formated to a max of", lLength, "characters per line: ") wr.width = lLength wr.expand_tabs = True for lines in wraped: print(lines) an example of what the output SHOULD be is this. If the file specified contains this text: hgytuinghdt #here the length is 11 ughtnjuiknshfyth #here the length is 16 nmjhkaiolgytuhngjuin #here the length is 20 and the lLength is specified to 15 then this should print out: hgytuinghdt ughtnjuiknshfyt h nmjhkaiolgytuhng juin Thanks.

    Read the article

1