Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
10327 views
ubuntu2004
Kernel: Python 3 (system-wide)

All of the following exercises use the string "The Chimpanzees of Gombe" stored in the variable title.

title = "The Chimpanzees of Gombe"

Exercise 6.1

  1. Print the characters at indicies 10, and -2 in the string.

  2. Print the first, and last characters in the string.

print(title[10]) print(title[-2]) print(title[0]) print(title[-1])
n b T e

Exercise 6.2

  1. Print the characters from indicies 4 to 13 inclusive in the string.

  2. Print the 20th to the last characters in the string.

print(title[4:13]) print(title[20:])
Chimpanze ombe

Exercise 6.3

  1. Print every other character in the string.

  2. Print the reverse of the string.

print(title[::2]) print(title[::-1])
TeCipneso ob ebmoG fo seeznapmihC ehT