In this program, we will print first character of each element inside a list
Create a list of city names
city = ['Paris','New York','London','Tokyo']
Finding number of elements inside a list using len() function
l = len(city)
print('Number of elements in a list',l)
Creating a variable i and assigning 0 value to it
i = 0
Now using while loop to print first character from each element inside a list
while i < l:
print(city[i][0])
i+=1
Output
Number of elements in a list 4
P
N
L
T
Complete Code
city = ['Paris','New York','London','Tokyo']
l = len(city)
print('Number of elements in a list',l)
i = 0
while i < l:
print(city[i][0])
i+=1