Ask Question
8 March, 11:58

Given a string, return a version without the first and last char, so "Hello" yields "ell". The string length will be at least 2. without_end ('Hello') → 'ell' without_end ('java') → 'av' without_end ('coding') → 'odin'

+2
Answers (1)
  1. 8 March, 13:15
    0
    def without_end (strg):

    if len (strg) >2:

    return strg[1:-1]

    else:

    return strg

    Explanation:

    Given above is a function in Python for solving this problem, we can try different output for this program by calling this function in a print statement

    print (without_end ("hello")) output ell

    print (without_end ("java")) output av

    print (without_end ("coding")) output odin
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Given a string, return a version without the first and last char, so "Hello" yields "ell". The string length will be at least 2. ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers