Question
Write a function split which takes two input arguments: a string to be split, a character to split on (also known as a delimiter). The
Write a function split which takes two input arguments: a string to be split, a character to split on (also known as a delimiter). The function will split the input string into smaller substrings, separated by the delimiter, and print each substring. Your function will return the number of pieces the string was split into.
Your function should be named split
Your function takes two input parameter arguments in the following order:
The string to be split.
A delimiter character, which marks where the input string should be split up.
Your function must return the number of substrings that the input string was split into as an integer.
Your function prints to the screen each substring that the delimiter separates the string into, each on its own line.
Example Input-Output:
Input: split(one small step, ); split returns: 3; output: one small step (each on its own line)
Input: split(cow/big pig/fish, /); split returns: 3; output: cow big pig fish (each on its own line)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started