Problem of grad becoming None

Can you check the answer in the below post and try using list.append() instead of list.extend()?