Complete the code to get the first character of the string.
word = "hello" first_char = word[[1]] print(first_char)
The first character of a string is at index 0.
Complete the code to get the last character of the string using negative indexing.
word = "world" last_char = word[[1]] print(last_char)
Negative index -1 gives the last character of the string.
Fix the error in the code to get the second last character using negative indexing.
word = "python" second_last = word[[1]] print(second_last)
Index -2 gives the second last character in the string.
Fill both blanks to get the middle character of the string 'abcde'.
word = "abcde" middle_char = word[[1] + [2]] print(middle_char)
The middle character is at index 2. Using 1 + 1 equals 2.
Fill all three blanks to create a dictionary with keys as characters and values as the negation of their position indexes in the string.
word = "code" index_map = { [1]: [2] for [3] in range(len(word)) } print(index_map)
This creates a dictionary where each character maps to the negation of its position index.
