Write loop that print out index of every I in mississippi
Answers
Explanation:
str1 = "Index10"
for index, char in enumerate(str1):
print("Current character", char, "position at", index )
Print out index of every I in mississippi
Explanation:
Python Program to print out index of every I in mississippi
lst = []
for index, character in enumerate('mississippi'):
if character == 'i':
lst.append(index)
print ("the index of i is:", lst)
Output
the index of i is: [1, 4, 7, 10]
OR
st="mississippi"
begin=0
letter="i"
for i in st:
if (i == letter):
print ("the index of i is: ", begin)
begin=begin+1
Output
the index of i is: 1 the index of i is: 4 the index of i is: 7 the index of i is: 10