-2

I am new to Python and I would like to know please how can I define a function that takes as much parameters as the user provides. For one parameter my function does the following:

def _more_data_(one_param):
    f = open(file,'w')
    f.write(str(one_param)+';\n')
    return

The function will eventually write all the input data the user provides in a a file names 'file'.

Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
Wallflower
  • 550
  • 1
  • 4
  • 13

1 Answers1

0

I think this answers your question.

def _more_data_(*args):
  f = open(file,'w')
  f.write(str(args[0])+';\n')
return

Or you can do this to write every argument you pass.

def _more_data_(*args):
  f = open(file,'w')
  for i in range(len(args)):
       f.write(args[i])
return

Happy to help : )