Questenaتمرینی که نشان می‌دهد بعد چه چیزی را مرور کنید
سؤال 99

What happens when Python evaluates "abc"[4]?

  1. It returns None.
  2. It returns 'c'.
  3. It raises KeyError.
  4. It raises IndexError.پاسخ درست

توضیح

The string has valid nonnegative positions 0 through 2, so direct access at 4 raises IndexError. Direct indexing does not clip an excessive position or return None as a sentinel.

ادامهٔ این آزمون

شروع تمرین
سؤال 99: What happens when Python evaluates "abc"[4]? · Python Fundamentals · Questena