''' This program does this: opens a file for writing generates 100 random numbers (each from 1 to 1000), and writes it, wraps the output line very 10 numbers ''' import random output_file_name = 'numbers_rand_wrapped.txt' out_handle = open(output_file_name, 'w') n_nums = 0 for i in range(1000): number = random.randrange(1,1001) out_handle.write(str(number) + ' ') n_nums += 1 if n_nums == 10: out_handle.write('\n') n_nums = 0 if n_nums > 0: out_handle.write('\n') out_handle.close()