I'm trying to write a function definition that takes a sequence and returns the first and second values. I suspect my code is wrong because it can't take in a list, but I'm not sure. Here's my goal:
Write a function definition named first_and_second that takes in sequence and returns the first and second value of that sequence as a list.
Here's the code I'm having trouble with:
def first_and_second(list):
return list[0 and 1]
Here's the test of whether I got it right:
assert first_and_second([1, 2, 3, 4]) == [1, 2]
assert first_and_second(["python", "is", "awesome"]) == ["python", "is"]