James's Jokes Repository

Question: How can we help James keep track of his jokes and show them in a specific format?

Helping James Track His Jokes

James is a talkative guy who likes to make jokes. However, he tends to use the same joke more than once, which can be a bit repetitive. To assist James in keeping track of his jokes, we need to take all the jokes he has used as input and follow these steps:
  1. Convert all jokes to lowercase: This ensures consistency in the format of the jokes.
  2. Remove duplicate jokes: To avoid repetition, we should only show James each joke once.
  3. Sort the jokes alphabetically: By organizing the jokes from 'a' to 'z', it will be easier for James to manage them.
  4. Replace consecutive spaces with a single space: This makes the jokes more readable and neat.

By following these steps, we can present James with his jokes in a clear and organized manner.

← Output of the code Clearing codes in vehicle diagnostic system →