Study Guide

7.1.5 Doghouse CodeHS Answers

7.1.5 Doghouse CodeHS Answers

The most common answer is:

my_string = "doghouse"

# Print "h" here
print(my_string[3])  # Indexing in Python starts from 0, so the 4th character is at index 3.

# Print "e" here
print(my_string[7])  # The 8th character is at index 7.

# Print "e" using a second index value (negative indexing)
print(my_string[-1])  # Negative indexing starts from the end, so -1 is the last character.