diff --git a/__pycache__/__init__.cpython-36.pyc b/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 0000000..be61b04 Binary files /dev/null and b/__pycache__/__init__.cpython-36.pyc differ diff --git a/q01_chocolates/__pycache__/__init__.cpython-36.pyc b/q01_chocolates/__pycache__/__init__.cpython-36.pyc index fa1b5bd..f2a107e 100644 Binary files a/q01_chocolates/__pycache__/__init__.cpython-36.pyc and b/q01_chocolates/__pycache__/__init__.cpython-36.pyc differ diff --git a/q01_chocolates/__pycache__/build.cpython-36.pyc b/q01_chocolates/__pycache__/build.cpython-36.pyc index 0e64e4d..cb872b9 100644 Binary files a/q01_chocolates/__pycache__/build.cpython-36.pyc and b/q01_chocolates/__pycache__/build.cpython-36.pyc differ diff --git a/q01_chocolates/build.py b/q01_chocolates/build.py index ed96c95..869958a 100644 --- a/q01_chocolates/build.py +++ b/q01_chocolates/build.py @@ -1,12 +1,27 @@ +# %load q01_chocolates/build.py -input_list = [] - +#input_list = [1,2,5,8] +input_list = [1,2,5,8] # Write your solution here: def q01_chocolates(my_list=input_list): - + + result_list = [] #empty list for number of element + previous_number =0 + + for element in my_list: + if element % 2 == 1: #condition to test element is odd + previous_number = previous_number + element + + result_list.append(previous_number) #append the result + + return result_list + +q01_chocolates() +l = [] +p = [l.append( element)if element%2 ==1 else l.append(l[len(l)-1]) for element in input_list ] diff --git a/q01_chocolates/tests/__pycache__/__init__.cpython-36.pyc b/q01_chocolates/tests/__pycache__/__init__.cpython-36.pyc index 7016538..0ab508c 100644 Binary files a/q01_chocolates/tests/__pycache__/__init__.cpython-36.pyc and b/q01_chocolates/tests/__pycache__/__init__.cpython-36.pyc differ diff --git a/q01_chocolates/tests/__pycache__/test_q01_chocolates.cpython-36.pyc b/q01_chocolates/tests/__pycache__/test_q01_chocolates.cpython-36.pyc index e3c45ac..e10a5fa 100644 Binary files a/q01_chocolates/tests/__pycache__/test_q01_chocolates.cpython-36.pyc and b/q01_chocolates/tests/__pycache__/test_q01_chocolates.cpython-36.pyc differ