I created a function which goes through excel files and sending the content to another Excel file. 

Also, it prints the output to the console and sending it to the DB. However, I would like to separate these three outputs and call this function to get only one output according my needs.

I know that I can call the function with parameter but it looks that in this it wont be possible because one part of code (or result) is done in internal loop and two others in external:

Let's see the simple code:

```
def function(param):
   for i in range(5):
      for x in range(10):
         worksheet.write    <--- writing into excel (row x column)
         array. append      <--- appending data to array (for future writing to database)
      print(appended data)  <--- printing on the console
      cursor.execute()      <--- pushing into database

```

I can imagine that if I put the if's before the print and else before the cursor, I can switch between these two. But how can I switch or conditioning the internal loop ?

My expected result is to get a different part of code according how I call the function.

Example: if I call `function(1)` I get the values into Excel, if I call `function(2)`, I will get data printed on the console. And if I call it with parameter 3, I get the data pushed into database.

Can you please point me out any idea ? 

Many thanks for your precious time.