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

bookChallenge: String Slicing and Indexing

Oppgave

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

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 4
single

single

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

close

Awesome!

Completion rate improved to 6.67

bookChallenge: String Slicing and Indexing

Sveip for å vise menyen

Oppgave

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 desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 4
single

single

some-alt