Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära Challenge: String Slicing and Indexing | String Manipulation Essentials
Working with Strings and Data Formats

bookChallenge: String Slicing and Indexing

Uppgift

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 char in text.
  • Find the index of the last occurrence of char in text.
  • Extract and return the substring that lies strictly between these two indices.
  • Return an empty string if char does not appear at least twice in text.

Lösning

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 1. Kapitel 4
single

single

Fråga AI

expand

Fråga AI

ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

Suggested prompts:

Can you explain this in simpler terms?

What are the main takeaways from this?

Can you give me an example?

close

Awesome!

Completion rate improved to 6.67

bookChallenge: String Slicing and Indexing

Svep för att visa menyn

Uppgift

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 char in text.
  • Find the index of the last occurrence of char in text.
  • Extract and return the substring that lies strictly between these two indices.
  • Return an empty string if char does not appear at least twice in text.

Lösning

Switch to desktopByt till skrivbordet för praktisk övningFortsätt där du är med ett av alternativen nedan
Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 1. Kapitel 4
single

single

some-alt