Data Engineering Lab

String Indexing & Slicing — Python practice

Q1: Meet string indexing — positive and negative indexes

Understand that every character in a string has both a positive index (0, 1, 2…) and a negative index (-1, -2, -3…). Use both to access characters at different positions.

Requirements

  • word = "Python"
  • Print word[0] → P (first character, positive index)
  • Print word[2] → t (middle character, positive index)
  • Print word[-1] → n (last character, negative index)
  • Output: P then t then n

Enable JavaScript to edit code, run the exercise, and review feedback. Your saved work loads in the existing practice workspace.