#K88217. Full Name Transformation
Full Name Transformation
Full Name Transformation
You are given a full name string that may contain extra spaces. The full name is provided in the format "First Middle1 Middle2 ... Last". Your task is to reformat the name into "Last, First" format. If the name does not contain at least two parts, you should output the error message: Full name must contain at least two parts
.
Note: The input might have leading and trailing spaces which should be ignored.
The mathematical verification is simple: Let the full name have parts \(N_1, N_2, \ldots, N_k\) with \(k \geq 2\). Then the expected output is \(N_k, N_1\).
inputFormat
The input consists of a single line containing the full name. The name may include leading or trailing spaces.
outputFormat
If the input is a valid full name (contains at least two parts), output a single line containing the transformed name in the format "Last, First". Otherwise, output Full name must contain at least two parts
.
Emily Jane Smith
Smith, Emily