KnowledgeBoat Logo

Computer Science

Find the errors. Find the line numbers causing errors.

  1. S = "PURA VIDA"
  2. S1 = S[: 10] +S[10 :]
  3. S2 = S[10] + S[-10]

Python String Manipulation

11 Likes

Answer

The error is in line 3. Length of string S is 9 so its forward indexes range for 0 to 8 and backwards indexes range from -1 to -9. S[10] and S[-10] are trying to access out of bound indexes.

Answered By

4 Likes


Related Questions