Feb-11-2018, 12:12 AM
# [ ] find and report (print) number of w's, o's + use of word "code"
work_tip = "Good code is commented code"
# [ ] count times letter "i" appears in code_tip string
# [ ] find and display the index of all the letter i's in code_tip
# Remember: if .find("i") has No Match, -1 is returned
code_tip = "code a conditional decision like you would say it"
print ("code_tip:" , code_tip)
my code:
work_tip = "Good code is commented code"
# [ ] count times letter "i" appears in code_tip string
# [ ] find and display the index of all the letter i's in code_tip
# Remember: if .find("i") has No Match, -1 is returned
code_tip = "code a conditional decision like you would say it"
print ("code_tip:" , code_tip)
my code:
code_tip = "code a conditional decision like you would say it" a = code_tip.count("w") b = code_tip.count("o") c = code_tip.count("code") print(a) print(b) print(c) cnt = code_tip.count("i") print(cnt) ind = code_tip.find("i") for i in code_tip: if code_tip.find("i"): print(ind) break else: print("not found") print ("code_tip:" , code_tip)I have a problem with bolded task. Don't know how to print indexes for all six i's. Help is appreciated.