How To Print A Word Letter By Letter In Python

In this tutorial, we will learn how to print a word letter by letter in Python. This is a useful skill to know when working with text processing, as it can help with tasks like text manipulation, encryption/decryption, and other applications where individual characters need to be processed.

Step 1: Get a user-inputted word

First, let’s get word from the user that we want to print letter by letter. We will use the input() function to obtain a string from the user.

Step 2: Print the word letter by letter using a for loop

We can use a for loop to iterate through each character in the string and print it.

When using a for loop, the variable ‘letter’ will take the value of each character in the ‘word’ one at a time. The print() function is called for each letter, outputting it to the console.

Full Code

Example Output

Enter a word: Python
P
y
t
h
o
n

In this example, the user entered the word “Python”. The program prints each letter in the word on a separate line.

Conclusion

In this tutorial, we’ve learned how to print a word letter by letter in Python using the input() function and a for loop. This technique is useful for text processing applications and can be expanded upon by adding more complex logic within the loop, such as counting the occurrences of a specific letter or modifying each character before printing it.