PythiloLesson 8 of 30 · progress kept in this browser

Indexing and slicing

Strings, lists and tuples are sequences. Each item has a position counted from 0, and negative positions count back from the end.

word = "python"
print(word[0], word[-1])  # p n
print(word[1:4])   # yth
print(word[:2])    # py
print(word[2:])    # thon
print(word[-3:])   # hon
print(word[::2])   # pto
print(word[::-1])  # nohtyp
Your task

Write mask(text) returning text with every character except the last 4 replaced by "#", leaving text of 4 characters or fewer unchanged. Write is_palindrome(word) returning whether word reads the same backwards, ignoring case.