Exercise 16 

Write a program in Python language that asks the user to enter a string s and then display him all the characters contained in this string.
Example for s = "Python", the program displays the characters:
P
y
t
h
o
n

Solutions

First method by using the len() method of the string

# Ask to type a string s
s = input("Type a string s : ")

# getting the len of the string s
n = len(s)
for i in range(0, n):
print(s[i])

Second method by accessing directly to the characters of string

# Ask to type a string s
s = input("Type a string s : ")
for x in s:
print(x)



Younes Derfoufi

One thought on “Solution Exercise 16”

Leave a Reply