166k views
3 votes
In Python, how would you print the first 4 characters of "Help me pass!"

User Felix Fung
by
5.9k points

1 Answer

1 vote

Answer:

sample_str = "Help me pass!"

first_chars = sample_str[0:4]

print('First four character: ', first_chars)

Step-by-step explanation:

sample_str = "Help me pass!"

first_chars = sample_str[0:4]

H has index 0, e has index 1, l has index 2, p has index 3. the space has an index as well, etc.

User Vurmux
by
5.0k points