> for i in range(0, len(values), 128): > # Step through the list of values, starting at 0, > # taking 128 items at a time. > temp = values[i:i+128] > # Join the values into a string. > s = ''.join(temp) > # And make a row with a label. > row = "Row" + str(counter) + " = " + s > print row > rows.append(row)
modified the code to be but it didnt print out anything: ###code from __future__ import with_statement def main(): rows = [] counter=1 #count row numbers values = [] with open('test2.txt') as f: for i in range(0,len(values),128): #step through the list of values, starting at 0, #taking 128 items at a time temp=values[i:i+128] #join the values into a string s=''.join(temp) #and make a row with a label. values.append(line.rstrip('\n')[-1]) row = "Row" + str(counter) + " = " + s print row rows.append(row) if __name__ == '__main__': main() ##### pls advise. tq
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor