Python Practice › Loop Programs › Program 48

Characters of a string into a list

EasyLoop Programs · 48 of 90

Write a Python program that adds every character of an input string to an empty list.

Advertisement
Input
sqatools007
Output
Enter text: sqatools007
['s', 'q', 'a', 't', 'o', 'o', 'l', 's', '0', '0', '7']

Approach

  1. Append each character in a loop.

Solution

Python
text = input("Enter text: ")chars = []for ch in text:    chars.append(ch)print(chars)
Outputtyped input: sqatools007
Enter text: sqatools007
['s', 'q', 'a', 't', 'o', 'o', 'l', 's', '0', '0', '7']
Tip

list(text) gives the same list in one call.

Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More loop programs

← All 90 Loop Programs