Ask Question
23 November, 03:27

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'

+1
Answers (1)
  1. 23 November, 03:43
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers