How to print the first letter from all the strings in a list of strings in Python

2 Answers

0 votes
lst = ["python", "java", "c#", "c++", "php"]

i = 0
while i < len(lst):
    print(lst[i][0])
    i += 1


'''
run:
 
p
j
c
c
p

'''

 



answered Dec 7, 2017 by avibootz
0 votes
lst = ["python", "java", "c#", "c++", "php"]

for i in range(len(lst)):
    print(lst[i][0])


'''
run:
 
p
j
c
c
p

'''

 



answered Dec 7, 2017 by avibootz
...