Write a program to split a given string on hyphens and display each substring.
Given:
str1 = Emma-is-a-data-scientist
Expected Output:
Displaying each substring Emma is a data scientist
Hint:
Use the string function split()
split()
Solution:
str1 = "Emma-is-a-data-scientist" print("Original String is:", str1) # split string sub_strings = str1.split("-") print("Displaying each substring") for sub in sub_strings: print(sub)
Explanation in video:
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Hint:
Use the string function
split()
Solution:
Explanation in video:
need an explanation for this answer? contact us directly to get an explanation for this answer