Challenge: String Slicing and Indexing
Swipe to start coding
Write a function that receives a string and a character, and returns the substring found between the first and last occurrence of the specified character in the string. If the character does not appear at least twice, return an empty string.
- Find the index of the first occurrence of
charintext. - Find the index of the last occurrence of
charintext. - Extract and return the substring that lies strictly between these two indices.
- Return an empty string if
chardoes not appear at least twice intext.
Solution
Merci pour vos commentaires !
single
Demandez à l'IA
Demandez à l'IA
Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion
Can you explain this in simpler terms?
What are the main takeaways from this?
Can you give me an example?
Awesome!
Completion rate improved to 6.67
Challenge: String Slicing and Indexing
Glissez pour afficher le menu
Swipe to start coding
Write a function that receives a string and a character, and returns the substring found between the first and last occurrence of the specified character in the string. If the character does not appear at least twice, return an empty string.
- Find the index of the first occurrence of
charintext. - Find the index of the last occurrence of
charintext. - Extract and return the substring that lies strictly between these two indices.
- Return an empty string if
chardoes not appear at least twice intext.
Solution
Merci pour vos commentaires !
single