I have a function which takes one compulsory file and other possible optional file. Currently the function can read and write single file from the user input. But I want to load and write as many files as user enters from the console input. For that, I want to define function for one compulsory filename and other as an optional parameters.
How do I ask users in console input to enter one compulsory file and other all possible optional filename (only if user wants) and read and write them separately in a function without mixing each other. I want to read and also write separately those all entered files.
Basically, I want to load all filenames which were entered by users in console input and write them separately in each new file.
Currently my function loads and read only one file from the user input.
def read_files(filename, *other):
with open(filename, 'rU') as f:
d = json.load(f)
Input for users:
if __name__ == '__main__':
filename = input('Enter your file name:')
#Here I am confused how do I ask the possible number of filename and How
#do i stop when the user enters all filename
other = input('Enter your other file name')
read_files(filename, )