subject

Write a function named count_letters that takes as a parameter a string and returns a dictionary that tabulates how many of each letter is in that string. the string can contain characters other than letters, but only the letters should be counted. the string could even be the empty string. lower-case and upper-case versions of a letter should be part of the same count. the keys of the dictionary should be the upper-case letters. if a letter does not appear in the string, then it would not get added to the dictionary. the dict and count function may not be used. for example, if the string is```"aabb"```then the dictionary that is returned should contain these key-value pairs: ```{'a': 2, 'b': 2}so far i am stuck at(which is not working correctly when given to capitalized values, ex "aa" returns 1): def count_letters(string): letter_dic = { } for letter in string: if letter in letter_dic: letter_dic[letter] = +1 else: letter_dic[letter] = 1 return letter_dic

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 04:30, kkeith121p6ujlt
Eye injuries usually occur as a result of all of the following things, except: a) proper machine operation b) battery explosion c) falling or flying debris d) electric welding arc
Answers: 2
image
Computers and Technology, 23.06.2019 00:10, witerose701
Write a function so that the main0 code below can be replaced by the simpler code that calls function mphandminutes tomiles0. original main0 int main) l double milesperhour-70.0; double minutestraveled = 100.0; double hourstraveled; double milestraveled; hourstraveled = minutestraveled / 60.0; milestraveled = hourstraveled * milesperhour; cout < "miles" 2 using namespace std; 4 /* your solution goes here/ 6 int maino 1 test passed 7 double milesperhour 70.0 all tests passed 8 double minutestraveled 100.0; 10 cout < < "miles: " < < mphandminutestomiles(milesper-hour, minutestraveled) < < endl; 12 return 0; 13
Answers: 1
image
Computers and Technology, 23.06.2019 18:30, milkshakegrande101
Where can page numbers appear? check all that apply. in the header inside tables in the footer at the bottom of columns at the top of columns
Answers: 1
image
Computers and Technology, 23.06.2019 21:00, shawnnoteman1234
Which task uses a simple parameter?
Answers: 1
You know the right answer?
Write a function named count_letters that takes as a parameter a string and returns a dictionary tha...

Questions in other subjects: