migrate to git.charlotte.sh
This commit is contained in:
commit
fbd588721e
412 changed files with 13750 additions and 0 deletions
11
python-csi160/week05/week-5Practice-Problems/part3.py
Normal file
11
python-csi160/week05/week-5Practice-Problems/part3.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
def last_element(list_to_search):
|
||||
"""Returns the last element of the supplied list.
|
||||
Returns None if the list is empty"""
|
||||
if len(list_to_search) == 0:
|
||||
return None
|
||||
return list_to_search[-1]
|
||||
|
||||
|
||||
# Leave this part for easily testing your function
|
||||
print('[4, 2, 15, 5] The last_element returns', last_element([4, 2, 15, 5]))
|
||||
print('[] The last_element returns', last_element([]))
|
Loading…
Add table
Add a link
Reference in a new issue