Question: I have a case where a program does 3 tasks, which has corresponding 3 *optional* arguments.
If **none** of the 3 arguments are passed, then **do all 3 tasks**.
But if any of arguments are specifically mentioned, then do only those task !

After going through the docs, I have come up with a solution, but feel it is not shortest or efficient way to do so.

In the `argparse` document, I used `store_false` to achieve it

```
my_parser.add_argument('-a', action='store_false')
my_parser.add_argument('-b', action='store_false')
my_parser.add_argument('-c', action='store_false')

```

But then I have to use the below logic to achieve my requirement.
Say if argument for task `a` and `c` are specified. So, we shouldn't do task `b`

```

a = False
b = True
c = False

l = [a,b,c]

if all(l):
    print("Do All 3 tasks")
else:
    if not a:
        print('Do task A ')
    if not b:
        print('Do task B')
    if not c:
        print('Do task C')

```

```
> python3 arg_check.py 
Do task A 
Do task C

```

But this a lot code i believe?

Is there any better way within the `argparse` library, that overrides the value of other arguments based on any other arguments ?

Answer: 
There's no reason to have 2 for loops, as you can split the item and put it into the format you want in a single for loop like so:

```py
# Import data for CSV

csv_file = open("csv_file.txt", "r")
list_csv = [x.strip() for x in csv_file.readlines()]

dictionary_item = []

for item in list_csv:
    x = item.split(",")
    dictionary_item.append({'club': x[0],
                            'city': x[1],
                            'country': x[2]})

print(dictionary_item)

```

Python also has [a built in CSV reader](https://docs.python.org/3/library/csv.html), which it might be better practice to use if you don't want to do everything manually.
When I first looked at your question I noticed that the for loops do almost the same thing. Here's how I was able to while keeping the output the same.

```
# Import data for CSV

csv_file = open("soccer_clubs.txt", "r")

dictionary_item = []

for x in csv_file.readlines():
    x.strip()
    dictionary_item.append({'club': x[0],
                            'city': x[1],
                            'country': x[2]})

print(dictionary_item)

```