diff --git a/__pycache__/__init__.cpython-36.pyc b/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 0000000..4aafdd0 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..ac5788b 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..1497327 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..871ed92 100644 --- a/q01_chocolates/build.py +++ b/q01_chocolates/build.py @@ -1,11 +1,37 @@ +# %load q01_chocolates/build.py -input_list = [] +input_list= [2, 5, 8, 11, 4] + # Write your solution here: def q01_chocolates(my_list=input_list): + list2=list() + newval=0 + if len(my_list)%2==0: + for index,num in enumerate(my_list): + if index%2==0: + newval=num+newval + else: + newval=list2[index-1] + list2.append(newval) + else: + for index,num in enumerate(my_list): + if index%2!=0: + newval=num+newval + else: + if index==0: + newval=0 + else: + newval=list2[index-1] + list2.append(newval) + return(list2) + +q01_chocolates() + + diff --git a/q01_chocolates/tests/__pycache__/__init__.cpython-36.pyc b/q01_chocolates/tests/__pycache__/__init__.cpython-36.pyc index 7016538..7b7de29 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..28ba9c9 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