Python Practice › String Programs › Program 90

Join words with hyphens

EasyString Programs · 90 of 106

Write a Python program to split a string and join it with “-“.

Advertisement
Input
"Sqatools is best"
Output
Sqatools-is-best

Approach

  1. "-".join(text.split()).

Solution

Python
print("-".join("Sqatools is best".split()))
Output
Sqatools-is-best
Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More string programs

← All 106 String Programs