Help with code

dan

Joined
Oct 21, 2024
Messages
1
Reaction score
0
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top