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)

You need to print count value

hay buddy work on this .
i have not check it but should work.

chunk_val = raw_input("chunk values : ").lower() # values to search

check_val = raw_input("check stuff : ").lower() # search values. dont repeat search values. eg values appears once for checking
data ={}  #dir to keep distinct

for c in chunk_val:    #ussual stuff
    for x in check_val:
        if x == c:
            print c+"\n";
            if c not in data.keys():
                data[c]=1
            else:
                data[c] = data.get(c)+1

print " ".join((["-" for x in range(10)]))
for x in data.values():
    print(x)


print data  # debug dir
initials = set(input("Initials : ").lower()) # unique initials
phrase = input("Phrase: ").lower()
print(sum(c in initials for c in phrase))
"""Output:
Initials : VKL
Phrase: Victor likes licking people
6
"""
def x():
    count = 0
    initials = input('enter your initials:\n').upper()
    text = input('enter your text:\n').upper()
    for initial in initials:
        if initial in text:
            count += 1
    print 'your text contains:', count , 'values from your initials'
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.