Učitavanje zadatka…
Checking the first and last elements is useful when a list should start and end with the same value. Write a function same_first_last that takes a list of numbers nums. Return True if the list is not empty and its first element equals its last element. If the list is empty or the edge values are different, return False.
[1, 2, 3]False[1, 2, 3, 1]True[1, 2, 1]Truedef same_first_last(nums: list[int]) -> bool:
Prijavi se da vidiš povijest predaja
PrijavaPrijavi se da koristiš AI mentora
Prijava[1,2,3]False[1,2,3,1]True[1,2,1]True[]False[5]True[0]True