Objective

Extract out individual words from a hyphenated word.

Difficulty

Very easy

Description

A hyphenated word is one that has the hyphen character (-) in it. Some examples are awe-inspiring, strongly-typed, small-sized, one-by-one etc.

In this exercise, you have to create a program that asks the user to input a hyphenated word and then displays each constituent word out on the document, one-by-one.

Start by asking the user to enter a hyphenated word with the message 'Enter a hyphenated word:'.

Once the word is entered, extract out the constituent words from it, and print each on a new line.

Shown below is an example:

Live Example

If the input value is invalid, alert 'Invalid input!' before asking the user to input again.

Hints