migrate to git.charlotte.sh

This commit is contained in:
Charlotte Croce 2025-04-19 23:42:08 -04:00
commit fbd588721e
412 changed files with 13750 additions and 0 deletions

View file

@ -0,0 +1,19 @@
'''
Do not use AI! You can schedule to try again if you have a bad grade!
Write a function named exactly "last2" which receives a list of elements as parameter and then return the second element
from the end to the beginning of the list. If the list has less than two elements, the function should return None.
Example:
print(last2(['red', 'blue', 'green', 'yellow'])) # Output: green
print(last2([0,1])) # Output: 0
print(last2([0])) # Output: None
'''
def last2(lst):
if len(lst) < 2:
return None
else:
return lst[-2]
print(last2(['red', 'blue', 'green', 'yellow'])) # Output: green
print(last2([0,1])) # Output: 0
print(last2([0])) # Output: None