mardi 26 janvier 2016

Python string word wrapping

I want to wrap an input string like "MISSISSIPPI,2,I" and the output must be like that M IS S IS S IP P I

MISSISSIPPI-word 2-2 maximum of n chars in length on a substring I- the char which substring can begin with

wordwrap outputs the substrings of a$ that are a maximum of n characters in length or that begin with the character b$. Substrings must be separated by spaces.

d =input('add char ')
line=input('addtext ')
w=inpit('chunk size ')
import re
k=line.split(d)
r=[line[i:i+w] for i in range(0,len(line),w)] 
j=[k[0]]+[d+1 for l in k[1:]]

for i in range(len(line))

 ....

Aucun commentaire:

Enregistrer un commentaire