Files
curriculum/1.solar-system/3.strings/01.the-message/index.md

43 lines
940 B
Markdown

---
type: challenge
title: "The Message"
xp: 50
duration: 25
difficulty: 2
---
# The Message
> **[INCOMING — Mission Control, Earth]**
>
> Cadet, a string is a *sequence of characters*. You can pick any
> one out by its position (its *index*).
>
> Indexes start at 0:
>
> ```
> M I S S I O N
> 0 1 2 3 4 5 6
> ```
>
> Negative indexes count back from the end. `s[-1]` is the last
> character.
>
> Strings are *immutable* — you can read any character, but you can't
> change one in place. To "modify" a string, you build a new one.
>
> Implement `info(s)` that returns a dict with four keys: `first`,
> `sixth`, `last`, `length`.
>
> [END TRANSMISSION]
## Your Task
Open `starter/starter.py`. Use `s[0]`, `s[5]`, `s[-1]`, and `len(s)`
to fill in the dict.
## Objectives
- `info("MISSION-CONTROL-7")` returns `{"first": "M", "sixth": "O", "last": "7", "length": 17}`
- Works for any non-empty string of length ≥ 6