159k views
4 votes
Write a Python function to get the first half of a specified string of even length. Suppose the input string is "Python" ,after calling the function, we should see the output "Pyt"

User Uaraven
by
5.0k points

2 Answers

1 vote

Answer:

c

Step-by-step explanation:

User DaoWen
by
5.5k points
1 vote

In python:

def get_even(txt):

return txt[0:int((len(txt) / 2))]

We can test our function with the following code:

print(get_even("Python")) This returns "Pyt" in the console.

I hope this helps!

User Han Bing
by
4.6k points