solve in python 3.8 please The question is about Strings
Modify your function so that it can handle the following two situations: The string given as an argument has no characters. In this case, you should return the empty string.
The string given as an argument has one character. In this case, you should return the one-character string given to you. Without any consideration for these cases, your
function probably causes an error or returns the wrong result in the event that it is given a zero-character or one-character string. Your function MUST still be called
get_string_ends. You can write code in the main part of your program to test your function, but when you submit, your code must ONLY have the function definition!
def get_string_ends(s):
if len(s) == 0:
return ""
elif len(s) == 1:
return s
else:
# remaining function definition
pass
# Test Code
if __name__ == '__main__':
print(get_string_ends(""))
print(get_string_ends("a"))
SCREENSHOT
OUTPUT
Get Answers For Free
Most questions answered within 1 hours.