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.
Oplossing
Bedankt voor je feedback!
single
Vraag AI
Vraag AI
Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.
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
Veeg om het menu te tonen
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.
Oplossing
Bedankt voor je feedback!
single