Strings
- Stage
- 1
- Module
- M1.7
- Lessons
- 1
In this module
- Find how many characters a string holds with
len(). - Read one character with indexing (
word[i]), including from the end with a negative index. - Take out part of a string with slicing (
word[a:b]). - Convert between a character and its code point with
ord()andchr().
Before this module
Lessons
Practice
Try these on the judge. Each link opens the problem on DMOJ.
- 2015 J2Happy or Sad (opens on DMOJ in a new tab) DMOJ
Count two kinds of faces in a line of text and decide whether it reads happy, sad, unsure, or neither.
Why DMOJ: Tries the same kind of problem on DMOJ, which holds 2014 to 2020.
- 2019 J2Time to Decompress (opens on DMOJ in a new tab) DMOJ
Turn each "count and character" line into that character repeated that many times.
Why DMOJ: Tries the same kind of problem on DMOJ, which holds 2014 to 2020.
- 2018 J2Occupy parking (opens on DMOJ in a new tab) DMOJ
Compare two lines and count where both mark the same spot.
Why DMOJ: Tries the same kind of problem on DMOJ, which holds 2014 to 2020.