Table of Contents

Print Characters in Word PYTHON using For Loop

Example Description
This code demonstrates a simple way to iterate through the letters of a string and print them individually.

Introduction:

This Python code snippet shows you how to use a for loop to print each character of the word PYTHON separately. It is a simple example that demonstrates the process of iterating through a string and accessing each character.

Code:

#Print the characters in word PYTHON using for loop
for letter in 'PYTHON':
 print(letter)

Logic:

  1. The code uses a for loop to iterate through the letters in the string “PYTHON”.
  2. For each letter, the print statement is executed to display it on the console.

Output:

>> P

>> Y

>> T

>> H

>> O

>> N