human
I am working on the file "Section 2 - Advance Python/Chapter S2.01 - Functional Programming/n/1 - About Functional Programming .ipynb".
The first task is:
Nested if statements in for loop
Can you write Python program for it?
assistant
#Here is the Python program you requested.

l = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0]

lst = []
for v in l:
    if v == 0 :
        lst.append ('Zero')
    else:
        if v % 2 == 0:
            lst.append  ('even')
        else:
            lst.append  ('odd')
            
print(lst)

lst = ["zero" if v == 0 else "even" if v%2 == 0 else "odd" for v in l]
print(lst)

print(['yes' if v == 1 else 'no' if v == 2 else 'idle' for v in l])

# def flatten_list_new(lst, result=None):
#     """Flattens a nested list
#         >>> flatten_list([ [1, 2, [3, 4] ], [5, 6], 7])
#         [1, 2, 3, 4, 5, 6, 7]
#     """
# #     if result is None:
# #         result = []
# #     else:
#     result = [x if not isinstance(x, list) else flatten_list_new(x, list) for x in lst]
# #     result = [ x  if not isinstance(x, list) else isinstance(x, list) for x in lst ]
# #     result = [x for x in a if not isinstance(x, list) else isinstance(x, list)]
# #     for x in a:
# #         if isinstance(x, list):
# #             flatten_list(x, result)
# #         else:
# #             result.append(x)

#     return result
# lst = [ [1, 2, [3, 4] ], [5, 6], 7]

# print(flatten_list_new(lst))

lst = []
for a in range(10):
    if a % 2==0:
        for x in range(a, 10):
            lst.append(x)
print(lst)

n = 10
lsts = [x for a in range(10) if a % 2==0 for x in range(a, 10) ]
print(lsts)

n = 10
lsts = [x for a in range(10) 
            if a % 2==0 
                for x in range(a, 10) ]
print(lsts)

%%time
import os

files = []

for d in os.walk(r"E:\code\mj\lep\Section 1 - Core Python"):
    for f in d[2]:
        if f.endswith(".py"):
            files.append(os.path.join(d[0], f))

print(len(files))

%%time

import os

files = [os.path.join(d[0], f) 
            for d in os.walk(r"E:\code\mj\lep\Section 1 - Core Python")
                 for f in d[2] if f.endswith(".py")]

print(len(files))

%%time

import os

files = [os.path.join(d[0], f) 
            for d in os.walk(r"E:\code\mj\lep\Section 1 - Core Python")
                 for f in d[2]  if...