Slice a City Name
Python
15 pts
Slice a City Name
Given city = "Massawa", create three variables using indexes and slicing:
first— the first characterlast— the last character (use a negative index)first_three— the first three characters
Print them in that order. Expected output:
M a Mas
Checklist
- Keep
cityunchanged and createfirst, its first character. - Create
last, the last character, using a negative index. - Create
first_three, the first three characters, using a slice. - Print
first,lastandfirst_three, one per line.
🔑 Solution
If you view the solution before passing, you earn half points for this exercise. You still need to type it and press Check to finish.
How it works, step by step
Point at a step to highlight its lines. Type the solution yourself and press Check answer to finish.
