SlideShare une entreprise Scribd logo
1  sur  1
Télécharger pour lire hors ligne
How to do? How to correct my code? WIth explanation pls. Thank you.
Define a function count_character which - accepts a string and counts the numbers of each
character in the string; and - returns a dictionary that store the results. For example: Answer:
(penalty regime: 10,20,% ) begin{tabular}{|r|c|c} hline 1 & def count_character(string): 2 & my_dict
= dict() 3 & for char in string: 4v & if char in my_dict: 5 & my_dict[char ]+=1 6 & else: 7 & my_dict [
char ]=1 8 & return my_dict 9 & 10 & 11 & my_dictionary = count_character(string) 12 &
end{tabular}

Contenu connexe

Plus de shahidipen68

Hindistandan Karayiplere gelen szlemeli hizmetiler yeni .pdf
Hindistandan Karayiplere gelen szlemeli hizmetiler yeni .pdfHindistandan Karayiplere gelen szlemeli hizmetiler yeni .pdf
Hindistandan Karayiplere gelen szlemeli hizmetiler yeni .pdfshahidipen68
 
Honeypots Youre responsible for the security of Xen Tech Li.pdf
Honeypots Youre responsible for the security of Xen Tech Li.pdfHoneypots Youre responsible for the security of Xen Tech Li.pdf
Honeypots Youre responsible for the security of Xen Tech Li.pdfshahidipen68
 
Hook Baif incorpotated processes king salmon for various dis.pdf
Hook Baif incorpotated processes king salmon for various dis.pdfHook Baif incorpotated processes king salmon for various dis.pdf
Hook Baif incorpotated processes king salmon for various dis.pdfshahidipen68
 
homogenous functions Consider the following functions Gx.pdf
homogenous functions   Consider the following functions Gx.pdfhomogenous functions   Consider the following functions Gx.pdf
homogenous functions Consider the following functions Gx.pdfshahidipen68
 
Hillyard Company an office supplies specialty store prepar.pdf
Hillyard Company an office supplies specialty store prepar.pdfHillyard Company an office supplies specialty store prepar.pdf
Hillyard Company an office supplies specialty store prepar.pdfshahidipen68
 
Homework Due on Mar 23 2023 Use Excel to draw a figure.pdf
Homework Due on Mar 23 2023  Use Excel to draw a figure.pdfHomework Due on Mar 23 2023  Use Excel to draw a figure.pdf
Homework Due on Mar 23 2023 Use Excel to draw a figure.pdfshahidipen68
 
Homework 6 Survey Report due 320 2023Homework 6 Survey R.pdf
Homework 6 Survey Report due 320 2023Homework 6 Survey R.pdfHomework 6 Survey Report due 320 2023Homework 6 Survey R.pdf
Homework 6 Survey Report due 320 2023Homework 6 Survey R.pdfshahidipen68
 
Homework Implement the Algorithm in Figure 11 using java Fi.pdf
Homework Implement the Algorithm in Figure 11 using java Fi.pdfHomework Implement the Algorithm in Figure 11 using java Fi.pdf
Homework Implement the Algorithm in Figure 11 using java Fi.pdfshahidipen68
 
Homework Unanswered Due Today 1159 PM Match the follow.pdf
Homework  Unanswered  Due Today 1159 PM Match the follow.pdfHomework  Unanswered  Due Today 1159 PM Match the follow.pdf
Homework Unanswered Due Today 1159 PM Match the follow.pdfshahidipen68
 
Hint Poisson splitting Jobs arrive to a data center with.pdf
Hint Poisson splitting Jobs arrive to a data center with.pdfHint Poisson splitting Jobs arrive to a data center with.pdf
Hint Poisson splitting Jobs arrive to a data center with.pdfshahidipen68
 
HIV as yapmak zordur nk ____ maliyet engelleyici vir.pdf
HIV as yapmak zordur nk ____   maliyet engelleyici  vir.pdfHIV as yapmak zordur nk ____   maliyet engelleyici  vir.pdf
HIV as yapmak zordur nk ____ maliyet engelleyici vir.pdfshahidipen68
 
How to fix these erros The method sortListltTgt in the.pdf
How to fix these erros The method sortListltTgt in the.pdfHow to fix these erros The method sortListltTgt in the.pdf
How to fix these erros The method sortListltTgt in the.pdfshahidipen68
 
How to do Wth Explanation pls Thank you Define a function.pdf
How to do Wth Explanation pls Thank you Define a function.pdfHow to do Wth Explanation pls Thank you Define a function.pdf
How to do Wth Explanation pls Thank you Define a function.pdfshahidipen68
 
HOW TO DO 2 20 marks The balance of payments accounts of.pdf
HOW TO DO 2 20 marks The balance of payments accounts of.pdfHOW TO DO 2 20 marks The balance of payments accounts of.pdf
HOW TO DO 2 20 marks The balance of payments accounts of.pdfshahidipen68
 
how to do this with vectors + strings C++ 2 Create Vector P.pdf
how to do this with vectors + strings C++ 2 Create Vector P.pdfhow to do this with vectors + strings C++ 2 Create Vector P.pdf
how to do this with vectors + strings C++ 2 Create Vector P.pdfshahidipen68
 
How should a permanent loss in value of an investment using .pdf
How should a permanent loss in value of an investment using .pdfHow should a permanent loss in value of an investment using .pdf
How should a permanent loss in value of an investment using .pdfshahidipen68
 
How many chromosomes are present in the cell before the star.pdf
How many chromosomes are present in the cell before the star.pdfHow many chromosomes are present in the cell before the star.pdf
How many chromosomes are present in the cell before the star.pdfshahidipen68
 
How prepared are you in the event of a disaster Describe yo.pdf
How prepared are you in the event of a disaster Describe yo.pdfHow prepared are you in the event of a disaster Describe yo.pdf
How prepared are you in the event of a disaster Describe yo.pdfshahidipen68
 
How tall is Gram 314x37159 499x37 x41992 inches .pdf
How tall is Gram 314x37159 499x37 x41992 inches .pdfHow tall is Gram 314x37159 499x37 x41992 inches .pdf
How tall is Gram 314x37159 499x37 x41992 inches .pdfshahidipen68
 
how the US health system is faring in terms of 1 improving .pdf
how the US health system is faring in terms of 1 improving .pdfhow the US health system is faring in terms of 1 improving .pdf
how the US health system is faring in terms of 1 improving .pdfshahidipen68
 

Plus de shahidipen68 (20)

Hindistandan Karayiplere gelen szlemeli hizmetiler yeni .pdf
Hindistandan Karayiplere gelen szlemeli hizmetiler yeni .pdfHindistandan Karayiplere gelen szlemeli hizmetiler yeni .pdf
Hindistandan Karayiplere gelen szlemeli hizmetiler yeni .pdf
 
Honeypots Youre responsible for the security of Xen Tech Li.pdf
Honeypots Youre responsible for the security of Xen Tech Li.pdfHoneypots Youre responsible for the security of Xen Tech Li.pdf
Honeypots Youre responsible for the security of Xen Tech Li.pdf
 
Hook Baif incorpotated processes king salmon for various dis.pdf
Hook Baif incorpotated processes king salmon for various dis.pdfHook Baif incorpotated processes king salmon for various dis.pdf
Hook Baif incorpotated processes king salmon for various dis.pdf
 
homogenous functions Consider the following functions Gx.pdf
homogenous functions   Consider the following functions Gx.pdfhomogenous functions   Consider the following functions Gx.pdf
homogenous functions Consider the following functions Gx.pdf
 
Hillyard Company an office supplies specialty store prepar.pdf
Hillyard Company an office supplies specialty store prepar.pdfHillyard Company an office supplies specialty store prepar.pdf
Hillyard Company an office supplies specialty store prepar.pdf
 
Homework Due on Mar 23 2023 Use Excel to draw a figure.pdf
Homework Due on Mar 23 2023  Use Excel to draw a figure.pdfHomework Due on Mar 23 2023  Use Excel to draw a figure.pdf
Homework Due on Mar 23 2023 Use Excel to draw a figure.pdf
 
Homework 6 Survey Report due 320 2023Homework 6 Survey R.pdf
Homework 6 Survey Report due 320 2023Homework 6 Survey R.pdfHomework 6 Survey Report due 320 2023Homework 6 Survey R.pdf
Homework 6 Survey Report due 320 2023Homework 6 Survey R.pdf
 
Homework Implement the Algorithm in Figure 11 using java Fi.pdf
Homework Implement the Algorithm in Figure 11 using java Fi.pdfHomework Implement the Algorithm in Figure 11 using java Fi.pdf
Homework Implement the Algorithm in Figure 11 using java Fi.pdf
 
Homework Unanswered Due Today 1159 PM Match the follow.pdf
Homework  Unanswered  Due Today 1159 PM Match the follow.pdfHomework  Unanswered  Due Today 1159 PM Match the follow.pdf
Homework Unanswered Due Today 1159 PM Match the follow.pdf
 
Hint Poisson splitting Jobs arrive to a data center with.pdf
Hint Poisson splitting Jobs arrive to a data center with.pdfHint Poisson splitting Jobs arrive to a data center with.pdf
Hint Poisson splitting Jobs arrive to a data center with.pdf
 
HIV as yapmak zordur nk ____ maliyet engelleyici vir.pdf
HIV as yapmak zordur nk ____   maliyet engelleyici  vir.pdfHIV as yapmak zordur nk ____   maliyet engelleyici  vir.pdf
HIV as yapmak zordur nk ____ maliyet engelleyici vir.pdf
 
How to fix these erros The method sortListltTgt in the.pdf
How to fix these erros The method sortListltTgt in the.pdfHow to fix these erros The method sortListltTgt in the.pdf
How to fix these erros The method sortListltTgt in the.pdf
 
How to do Wth Explanation pls Thank you Define a function.pdf
How to do Wth Explanation pls Thank you Define a function.pdfHow to do Wth Explanation pls Thank you Define a function.pdf
How to do Wth Explanation pls Thank you Define a function.pdf
 
HOW TO DO 2 20 marks The balance of payments accounts of.pdf
HOW TO DO 2 20 marks The balance of payments accounts of.pdfHOW TO DO 2 20 marks The balance of payments accounts of.pdf
HOW TO DO 2 20 marks The balance of payments accounts of.pdf
 
how to do this with vectors + strings C++ 2 Create Vector P.pdf
how to do this with vectors + strings C++ 2 Create Vector P.pdfhow to do this with vectors + strings C++ 2 Create Vector P.pdf
how to do this with vectors + strings C++ 2 Create Vector P.pdf
 
How should a permanent loss in value of an investment using .pdf
How should a permanent loss in value of an investment using .pdfHow should a permanent loss in value of an investment using .pdf
How should a permanent loss in value of an investment using .pdf
 
How many chromosomes are present in the cell before the star.pdf
How many chromosomes are present in the cell before the star.pdfHow many chromosomes are present in the cell before the star.pdf
How many chromosomes are present in the cell before the star.pdf
 
How prepared are you in the event of a disaster Describe yo.pdf
How prepared are you in the event of a disaster Describe yo.pdfHow prepared are you in the event of a disaster Describe yo.pdf
How prepared are you in the event of a disaster Describe yo.pdf
 
How tall is Gram 314x37159 499x37 x41992 inches .pdf
How tall is Gram 314x37159 499x37 x41992 inches .pdfHow tall is Gram 314x37159 499x37 x41992 inches .pdf
How tall is Gram 314x37159 499x37 x41992 inches .pdf
 
how the US health system is faring in terms of 1 improving .pdf
how the US health system is faring in terms of 1 improving .pdfhow the US health system is faring in terms of 1 improving .pdf
how the US health system is faring in terms of 1 improving .pdf
 

Dernier

4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxDIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxMichelleTuguinay1
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmStan Meyer
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4JOYLYNSAMANIEGO
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSMae Pangan
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfPatidar M
 
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvRicaMaeCastro1
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
Using Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea DevelopmentUsing Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea Developmentchesterberbo7
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxVanesaIglesias10
 
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptxMan or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptxDhatriParmar
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationdeepaannamalai16
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdfMr Bounab Samir
 
Mental Health Awareness - a toolkit for supporting young minds
Mental Health Awareness - a toolkit for supporting young mindsMental Health Awareness - a toolkit for supporting young minds
Mental Health Awareness - a toolkit for supporting young mindsPooky Knightsmith
 

Dernier (20)

Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxDIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and Film
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHS
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdf
 
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
Using Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea DevelopmentUsing Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea Development
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptx
 
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptxMan or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
 
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of EngineeringFaculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentation
 
Paradigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTAParadigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTA
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdf
 
Mental Health Awareness - a toolkit for supporting young minds
Mental Health Awareness - a toolkit for supporting young mindsMental Health Awareness - a toolkit for supporting young minds
Mental Health Awareness - a toolkit for supporting young minds
 

Count characters in a string and return as dictionary

  • 1. How to do? How to correct my code? WIth explanation pls. Thank you. Define a function count_character which - accepts a string and counts the numbers of each character in the string; and - returns a dictionary that store the results. For example: Answer: (penalty regime: 10,20,% ) begin{tabular}{|r|c|c} hline 1 & def count_character(string): 2 & my_dict = dict() 3 & for char in string: 4v & if char in my_dict: 5 & my_dict[char ]+=1 6 & else: 7 & my_dict [ char ]=1 8 & return my_dict 9 & 10 & 11 & my_dictionary = count_character(string) 12 & end{tabular}