Computer Science, asked by susanstamang7725, 9 months ago

Write loop that print out index of every I in mississippi

Answers

Answered by BushrajavediqbalKhan
2

Explanation:

str1 = "Index10"

for index, char in enumerate(str1):

   print("Current character", char, "position at", index )

Answered by suskumari135
6

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

Similar questions