KnowledgeBoat Logo

Computer Science

Given str1 = "Hello", what will be the values of:

(a) str1[0]

(b) str1[1]

(c) str1[-5]

(d) str1[-4]

(e) str1[5]

Python Data Handling

80 Likes

Answer

(a) H

(b) e

(c) H

(d) e

(e) IndexError: string index out of range

Explanation

H05e14l23l32o41\begin{matrix} \underset{-5}{\overset{0}\bold{H}} & \underset{-4}{\overset{1}\bold{e}} & \underset{-3}{\overset{2}\bold{l}} & \underset{-2}{\overset{3}\bold{l}} & \underset{-1}{\overset{4}\bold{o}} \end{matrix}

Answered By

25 Likes


Related Questions