easy string formating question
akameswaran at gmail.com
akameswaran at gmail.com
Thu Aug 10 15:13:04 EDT 2006
here's a simple way
numChar = 10
testText="akfldjliugflkjlsuagjlfnflgj"
for c in xrange(0,len(testText),numChar):
print testText[c,c+numChar]
for slightly better performance you should probably do
numChar = 10
testText="akfldjliugflkjlsuagjlfnflgj"
lenText = len(testText)
for c in xrange(0,lenText,numChar):
print testText[c,c+numChar] # don't worry about over indexing it's
handled cleanly
f pemberton wrote:
> I have kind of an interesting string, it looks like a couple hundred
> letters bunched together with no spaces. Anyway, i'm trying to put a
> "?" and a (\n) newline after every 100th character of the string and
> then write that string to a file. How would I go about doing that? Any
> help would be much appreciated.
More information about the Python-list
mailing list