I was trying to do the following exercise: Consider the sentence 'Jim quickly realized that the beautiful gowns are expensive'. Create a dictionary count_letters with keys consisting of each unique letter in the sentence and values consisting of the number of times each letter is used in this sentence. Count upper case and lower case letters separately in the dictionary.
Below is my code, and I think it's doing what the exercise is asking, but for some reason it still says that I did not do it right. Any ideas, anyone?
sentence = 'Jim quickly realized that the beautiful gowns are expensive'
count_letters = {}
cnt_lowercase = 0
cnt_uppercase = 0
#write your code here!
for c in sentence:
if c.islower():
if (c in count_letters) == False:
count_letters[c]={c:sentence.count(c)}
cnt_lowercase += 1
if c.isupper():
if (c in count_letters) == False:
count_letters[c]={c:sentence.count(c)}
cnt_uppercase += 1
print(str(cnt_lowercase))
print(str(cnt_uppercase))
print(count_letters)