Problem 791
First and Last Character
Easy · 10 pts · String, Basics
Problem
Read a word and print its first character and its last character, separated by a space. For a word with a single character, that character is both the first and the last, so it is printed twice. In most languages the first character is at index 0 and the last at index length - 1.
Input
A single word W of English letters.
Output
Print the first and the last character of W, separated by a space.
Constraints
1 <= |W| <= 100000
Example input
Python
Example output
P n
Explanation
In Python, the first character is P and the last is n, so the answer is P n.