The most common answer is:
string = "pbj"
def sandwich(string):
return string[0] + string[-1]
print(sandwich(string))
This code defines a function named sandwich
that takes a string as input and returns a new string consisting of the first and last characters of the input string. For the input “pbj”, it will output “pj”.