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.
Soluzione
Grazie per i tuoi commenti!
single
Chieda ad AI
Chieda ad AI
Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione
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
Scorri per mostrare il 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.
Soluzione
Grazie per i tuoi commenti!
single