130k views
4 votes
Create a function get_ends that consumes a string and returns a tuple of two values: the first letter of the string and the last letter of the string, both upper-cased. For example, the string "Python" would return ("P", "N"). Call this function on a string of your choice and assign the result to two variables (using multiple assignment), and then print each variable.

User Spankajd
by
5.2k points

1 Answer

2 votes

Answer:

Following are the program in the python language

def get_ends(s1): #define function

return(s1[0].upper(), s1[-1].upper()) #returning the first and last letter of the string s1

#function calling

f1,l1 = get_ends("python")

print(f1,l1) #print the first and last letter of the string.

Output:

P N

Step-by-step explanation:

In this program we create a function get_ends() which returning the first and last letter of the string s1 .

After returning the string will store in f1,l1 respectively .

Finally we print the first and last letter of the string .

User Gant Laborde
by
4.9k points