This is Python language.
Hello, I'm trying to make a program where the user enters his/her initials followed by a block of text. After that, the program will print out the number of times his/her initials showed up in the block of text.
For example, if my initials are VKL, and I type "Victor likes licking people" as the block of text (that's kinda gross), the program should print out "Your string contained 6 matches from your initials." 'V' appeared once, 'K' appeared twice, and 'L' appeared three times, so that adds up to 6.
Below is the code I came up with so far. Can anyone assist me from here? What loop is best to use?
#Prompt user to enter their initials. count = 0 initials = input("Please enter your initials.") #Prompt user to enter a block of text. text = input("Please enter a line of text.") #THIS DOES NOTHING FOR SOME REASON for c in text.lower(): if c in initials.lower(): count = count+1 #Print the block of text. print(text)
Edited by stealthless