In this program, we will take a string as input and split and join a string.
Steps to solve the program
- Take a string as input.
- Split the given string using Split().
- Join the splitter string using join() and “–“.
- Print the output.
#input string
string = "Hello world"
#Splitting the string
new_str = string.split(" ")
print(new_str)
#Joinin using -
print("-".join(new_str))
Output :
['Hello', 'world']
Hello-world