Data types · 20 / 29 Exercise Easy

Spaces to hyphens

Objective

Create a Python program that turns a sentence into a hyphen-joined string and counts its words.

Instructions

  • Read a sentence whose words are separated by a single space.
  • On the first line show the sentence with the spaces replaced by hyphens (-).
  • On the second line show the number of words.
Input
aprender python es divertido
Output
aprender-python-es-divertido
4

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise