Use python to write a script to perform the following task. Usethe simplest way you can come up with.
Your program/script takes two inputs: a file (containing singlecolumn tokens) and a number
which will be the number of columns in the output (example belowshows 3 columns):
input file:
t1
t2
t3
t4
t5
… many more tokens
output :
t1 t2 t3
t4 t5 t6
…..
Solution
Thanks for the question, here is the how it needs to bedone. Go through the code, all important lines are commentedout.
==============================================================================================
# takes in two arguments# filename of the file to be read# the number of columnsdef display_as_columns(filename,cols): with open(filename,’r’) as infile:
OR
OR