This is the problem statement,
Write a program that takes a list of words L as input and sorts the list of words in ascending alphabetical order. From the sorted list, identify the words that start with a given character C and print the original words along with their positions in the sorted list if they start with the specified character,
Read the input from STDIN and write the output to STDOUT. You should not write arbitrary strings while reading the input and while printing as these contribute to the standard
ii) If none of the words of the sorted list are starting with a given character then print 0.
Input Format:
The first line of input should contain L, a list of words in lowercase or upper case. The second line of input should contain a character C which refers to a character to be searched.
Output Format
The list of words and their position both should be separated by a single white space and every word will be in a separate line.
Sample Input1:
Planet earth is our home
e
Sample Output Should Be:
earth 1
I need help with the code, I greatly appreciate if you can help me out. Ones I tried end up getting wrong output
Write a program that takes a list of words L as input and sorts the list of words in ascending alphabetical order. From the sorted list, identify the words that start with a given character C and print the original words along with their positions in the sorted list if they start with the specified character,
Read the input from STDIN and write the output to STDOUT. You should not write arbitrary strings while reading the input and while printing as these contribute to the standard
ii) If none of the words of the sorted list are starting with a given character then print 0.
Input Format:
The first line of input should contain L, a list of words in lowercase or upper case. The second line of input should contain a character C which refers to a character to be searched.
Output Format
The list of words and their position both should be separated by a single white space and every word will be in a separate line.
Sample Input1:
Planet earth is our home
e
Sample Output Should Be:
earth 1
I need help with the code, I greatly appreciate if you can help me out. Ones I tried end up getting wrong output