Skip to content
Programs · Program 6-6

Q.Program 6-6: Program to print the characters in the string ‘PYTHON’ using for loop.

Sikkim CbseNCERTSubjective· 2mImportance★★★★★est
26% · 10/39 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

Strings are iterable in Python, so for ch in 'PYTHON': hands the loop one character at a time — the program prints P, Y, T, H, O, N on six lines.

The idea. A for loop in Python iterates over any sequence, not just range(). A string is a sequence of characters, so the loop variable receives each character in order — the cleanest way to process text character by character, with no manual indexing.

# Program 6-6: print the characters of the string 'PYTHON'
for ch in 'PYTHON':
    print(ch)

Expected output

P
Y
T
H
O
N

How it works

  • On the first pass ch = 'P', on the second ch = 'Y', and so on, in the exact left-to-right order of the string.
  • print(ch) ends each character with a newline, so every character appears on its own line.
  • The loop runs len('PYTHON') = 6 times and then stops automatically. …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.