**This Kata is intended as a small challenge for my students**

All Star Code Challenge #18

Create a function called that accepts 2 string arguments and returns an integer of the count of occurrences the 2nd argument is found in the first one.

If no occurrences can be found, a count of 0 should be returned.

Notes:
* The first argument can be an empty string  
* The second string argument will always be of length 1

Difficulty: introductory

Starter code:

def str_count(strng, letter):
	

Solutions:
def str_count(strng, letter):
    counter = 0
    
    for chr in strng:
        if chr == letter:
            counter += 1
        
    return counter

def str_count(strng, letter):
    return (strng.count(letter))

def str_count(string, letter):
    return string.count(letter)

str_count = lambda strng, letter: strng.count(letter)

# return count of occurrences the 2nd argument is found in the first one
# input - two strings
# output - integer
# edge cases - empty strings for first argument, in that case return 0


def str_count(strng, letter):
# start counting from 0
    count = 0
# loop over every element in string
    for e in strng:
# if element is equal to letter in second argument
        if e == letter:
# add element to the count
            count += 1
# return count of letter in string
    return count



def str_count(_str: str, letter: str) -> int:
    """ Get an integer of the count of occurrences the letter is found in the given string. """
    return _str.count(letter)

def str_count(strng, letter):
    count = 0
    if letter in strng:
        for i in range(len(strng)):
            if strng[i] == letter:
                count += 1
        return count
    else:
        return 0

def str_count(strng, letter):
    count = 0
    for i in strng:
        if i == letter:
            count += 1
    return count if count != 0 else 0

def str_count(st, l):
    return st.count(l)

import re
def str_count(strng, letter):
   return len(strng.split(letter)) - 1

def str_count(strng, letter):
    return sum([ch == letter for ch in strng])

def str_count(string, letter):
    return sum(map(lambda x: x == letter, string))

def str_count(strng, letter):
    from collections import Counter
    temp = Counter(strng)
    try:
        return temp[letter]
    except:
        return 0


def str_count(strng, letter):
    if strng in ['']:
        return 0
    else:
        return strng.count(letter)


def str_count(strng, letter):
    count =0
    for i in range(0,len(strng)):
        if strng[i] == letter:
            count = count +1
    return count

def str_count(strng, letter):
    return strng.count(letter, 0, len(strng))

str_count=lambda x,y:x.count(y)#(strng, letter):


def str_count(strng, letter):
    count = 0
    for i in strng:
        if i == letter:
            count += 1
    return count

def str_count(string: str, letter: str) -> int:
    """ This function returns an integer of the count of occurrences the 2nd argument is found in the first one. """
    count_letter = 0
    for i in string:
        if i == letter:
            count_letter += 1
    return count_letter

def str_count(string, letter):
    # Your code here ;)
    count=0
    if string == '':
        return 0
    else:
        for i in range(len(string)):
            if string[i] == letter:
                count=count+1
    return count
        


def str_count(strng, letter):
    x=0
    for i in range(len(strng)):
        if strng[i]==letter:
            x+=1
    return x 

def str_count(strng, letter):
    c = 0
    for char in strng:
        if letter == char:
            c+=1
    return c

def str_count(strng, letter):
    # Without using count method.
    count = 0
    for i in strng:
        if i == letter:
            count += 1
    
    return count

def str_count(strng, letter):
    strn = 0
    for i in strng:
        a = i.count(letter)
        strn += a
    return strn

def str_count(strng, letter):
    x = list(strng)
    y = 0
    for k in x:
        if k == letter:
            y += 1
        else:
            y += 0
    return y
    # Your code here ;)


def str_count(string, letter):
    counter = 0
    
    for n in string:
        if n == letter:
            counter += 1
        else:
            counter + 0
            
    return counter
            
    
    # Your code here ;)


def str_count(strng, letter):
    sum=0
    for i in range(0,len(strng)):
        if letter==strng[i]: sum+=1
    return sum


def str_count(string, letter):
    res = 0
    for c in string.lower():
        res += 1 if c == letter else 0
    return res

def str_count(strng, letter):
    count = 0
    for letr in strng:
        if letter == letr: count += 1
        else: count += 0
    return count

def str_count(strng, letter):
    # Your code here ;)
    count = 0
    
    for alphabet in strng:
        if letter == alphabet:
            count += 1
    return count


def str_count(a, b):
    count=0
    for i in a:
        if b==i:
            count+=1
    return count

def str_count(string, letter):
    count = 0
    for l in string:
        if letter == l:
            count += 1
    return count

from collections import Counter

def str_count(strng, letter):
    tot = Counter(strng)
    
    return tot[letter]

def str_count(strng, letter):
    if strng:
        return strng.count(letter)
    else: 0 

def str_count(strng,
              letter):

    return strng.count(letter)


str_count = lambda s,l : len([i for i in range(len(s)) if s.startswith(l, i)])

def str_count(strng, letter):
    sm = 0
    for i in strng:
        if i == letter:
            sm += 1
    return sm

def str_count(string, letter):
    res=0
    for i in string:
        if i==letter:
            res+=1
    return res

def str_count(strng, letter):
    Liste=list(strng)
    #print(Liste)
    Counts=dict()
    for ch in Liste:
        if ch not in Counts:
            Counts[ch]=1
        else:
            Counts[ch]=Counts[ch]+1
    #print(Counts)
    if letter in Counts:
        return Counts[letter]
    else:
        return 0

    return Counts[letter]

def str_count(strng, letter):
    soln = 0
    
    for char in strng:
        if char == letter:
            soln += 1
    return soln

def str_count(strng, letter):
    # Your code here ;)
    i = 0
    n = 0
    while i <= len(strng) - 1:
        for j in strng: 
            if j == letter:
                n = n + 1
                
        i = i + 1
        return n


def str_count(strng, letter):
    counter = 0
    for char in strng:
        if letter==char:
            counter +=1
    return counter

def str_count(strng, letter):
    """(^__^)"""
    return strng.count(letter)


def str_count(strng, letter):
    import re
    list = re.findall(letter, strng)
    return len(list)


def str_count(strng, letter):
    arr = []
    for j in letter:
        for i in strng:
            if j == i:
                arr.append(j)
    return len(arr)


def str_count(strng, letter):
    k = 0
    for i in strng:
        if letter == i:
            k += 1
    return k

def str_count(strng, letter):
    letter_count = {letter: 0}
    
    for char in strng:
        if char == letter:
            letter_count[char] += 1
    
    return letter_count[letter]

def str_count(strng, letter):
    strngL = list(strng)
    letterCount = 0 
    for i in range(len(strngL)): 
        if strngL[i] == letter: 
            letterCount += 1
    return letterCount

def str_count(string, letter):
    amount = 0
    for l in string:
        if l == letter:
            amount += 1
    return amount


def str_count(strng, letter):
    ans = 0
    for c in strng:
        if c == letter:
            ans += 1
    return ans

def str_count(strng, letter):
    letter_count = 0
    for i in strng:
        if i == letter:
            letter_count += 1
    return letter_count

def str_count(str, letter):
    c = 0
    for l in str:
        if l == letter:
            c += 1
    return c

def str_count(strng, letter):
    return strng.count(letter) if len(strng)>0 and letter  in strng  else 0

def str_count(st, letter):
    r = 0
    for i in st: 
        if i == letter: r += 1
    return r

def str_count(strng: str, letter: str) -> int:
    return strng.count(letter)

def str_count(string, letter):
    return len([s for s in string if s == letter])

def str_count(string, letter):
    count = 0
    for c in string:
        if letter == c:
            count += 1
    return count

def str_count(string, letter):
    return string.count(letter) if len(string) > 0 else 0

def str_count(strng, letter):
    answer=0
    x=0
    length=len(strng)
    while x<length:
        if strng[x]==letter:
            answer=answer+1
        x=x+1
    return answer


def str_count(strng, letter):
    
#    return sum(1 for x in strng if x == letter)
    
    count = 0
    for i in strng:
        if i == letter:
            count += 1
        else:
            count 
    return count

def str_count(strng, letter):
    count = 0
    for i in range(len(strng)):
        if strng[i] == letter[0]:
            count += 1
    return count

def str_count(strng, letter):
    count = 0 
    for check in(strng):
        if check == letter:
            count += 1
    return count


def str_count(strng, letter):
    if strng.find(letter)==-1:
        return 0
    else :
        return strng.count(letter)


def str_count(strng, letter):
    for i in strng:
        if strng.count(letter) >= 0:
            return strng.count(letter)

def str_count(string, letter):
    m=string.count(letter)
    return m
   
               
        
    # Your code here ;)


def str_count(string, letter):
    result = 0
    for i in string:
        if i == letter:
            result += 1
    return result

def str_count(strng, letter):
    val = 0
    for alpha in strng:
        if letter == alpha:
            val += 1
    print(val)
    return val


def str_count(strng, letter):
    total = 0
    for i in range(len(strng)):
        if letter == strng[i]:
            total += 1
    return total

def str_count(strng, letter):
    count = 0
    i = 0
    if len(strng) == 0:
        return count
    else:
        for letters in strng:
            if strng[i] == letter[0]:
                count += 1
                i += 1
            else:
                i += 1
        return count

def str_count(string, letter):
    counter = 0
    for i in string:
        if i == letter:
            counter = counter + 1
    return counter

def str_count(strng, letter):

    if letter not in strng:
        return 0
    else:
        return 1 + str_count(strng.replace(letter,"",1), letter)

def str_count(strng, letter):
    return strng.count(letter) # can't spll

def str_count(strng, letter):
    # Your code here ;)
    maara = strng.count(letter)
    return(maara)

def str_count(strng, letter):
    count = 0
    for i in strng:
        if i == letter:
            count +=1
        else:
            pass
    return count

def str_count(strng, letter):
    i = 0
    for c in strng:
        if c == letter:
            i +=1
    return i

def str_count(strng, letter):
    arr = list(strng)
    i=0
    for item in arr :
        if item == letter :
            i+=1
    return i
            
    # Your code here ;)


def str_count(strng, letter):
    return len(["big ass" for x in strng if x == letter])

def str_count(s, r):
    return len([x for x in s if x==r])

import re
def str_count(strng, letter):
    x = re.findall(letter, strng)
    return len(x)

def str_count(strng, letter):
    instances = 0
    for char in strng:
        if char == letter:
            instances += 1
    return instances

def str_count(strng, letter):
    quantity_letter = 0
    for i in strng:
        if i == letter:
            quantity_letter = quantity_letter + 1
    return quantity_letter

def str_count(strng, letter):
    res = 0
    for simv in strng:
        if simv is letter:
            res = res + 1
    return res

def str_count(stroka, letter):
    spisok = list(stroka)
    razi = 0
    x = 0
    while x != len(spisok):
        if spisok[x] == letter:
            razi = razi +1
            x=x+1
        else:
            x=x+1
    return razi

def str_count(string, letter):
    total = 0
    for i in string:
        if i == letter:
            total += 1
        else:
            pass
    return total      


def str_count(strng, letter):
    a=0
    for i in strng:
        if letter==i:
            a=a+1
    return a

def str_count(strg, letter):
    # Your code here ;)
    return strg.count(letter)


def str_count(strng, letter):
    a = 0
    for l in strng:
        if l == letter:
            a += 1
    return a


def str_count(strng, letter):
    j = 0
    for i in range (0, len(strng)):
        if strng[i] == letter:
            j += 1
    return j

def str_count(strng, letter):
    y = 0
    for n in strng:
        if n == letter:
            y += 1
    return y

def str_count(strng, letter):
    count_letter = 0 
    for i in strng:
        if letter == i:
            count_letter += 1 
    return count_letter         

def str_count(strng, letter):    
    return sum(True for x in strng if x == letter)

def str_count(strng, letter):
    # Your code here ;)
    count=0
    x=0
    while(x<len(strng)):
        if(letter == strng[x]):
            count+=1
        x+=1
    return count

def str_count(strng, letter):
    count = 0
    for i in strng:
        if i == letter:
            count += 1
    return count

str_count('hello', '')

def str_count(strng, letter):
    total = 0
    for i in range(len(strng)):
        if strng[i] == letter:
            total += 1
    return total

def str_count(string, letter):
    # Your code here ;)
    count = 0
    for i in range(len(string)):
        if letter in string[i]:
            count += 1
    return count

def str_count(strng, letter):
    count = 0
    for item in strng: 
            if item in letter: 
                count+= 1
    return(count)