Question: Counting Characters in String

Hi I'm trying to write a proc to takes a character and a string as inputs and as output tells you how many times the character shows up in the string.
I don't know what is wrong with the code


 s:=proc(Z)

local counts,C,i,L:

for C from "a" to "z" do
counts[C]:= 0:
end do:
L:=length(Z):
for i from 1 to L do
C:=Z[i];
if C >= "a" and C <= "z" then
counts[C] := counts[C] + 1
end if;
print(C,counts):
end do:
end:
Please Wait...