Walrus Target Lands in the Function, Not Global
def find_evens(nums):
evens = [last_even := x for x in nums if x % 2 == 0]
return evens
result = find_evens([1, 2, 3, 4, 5, 6])
print(result)
print(last_even)
What happens when this runs?
Sign in to answer questions and track your progress
Sign In