Problem 157854 · easy · Phase 01 Prerequisites & Setup

Bookends

strings · indexing

Given a string s, return a new string made of its first character followed by its last character. If s is empty return "". If s has just one character, that character counts as both the first and the last.

Examples

Input:  s = "python"
Output: "pn"

Input:  s = "x"
Output: "xx"

Input:  s = ""
Output: ""

Constraints

  • 0 <= len(s) <= 1000
  • s may contain letters, digits, spaces and punctuation

Goals

  • Read the first and last character with indexing
  • Handle an empty string and a one-character string
Starting Python…