Coder Social home page Coder Social logo

mullaghori / pretty-character-count Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 8 KB

It's a practice program for python beginners.

Python 100.00%
python python3 python-3 python-script beginner-project practice-project pretty-print pretty-character-counter

pretty-character-count's Introduction

From the book: Automate the Boring Stuff with Python. Writer: Al Sweigart

Pretty Character Count

It's a practice project for python beginners.

HINT: If you import the pprint module into your programs, you’ll have access to the pprint() and pformat() functions that will “pretty print” a dictionary values. This is helpful when you want a cleaner display of the items in a dictionary than what print() provides.

Modify the previous characterCount.py program and save it as prettyCharacterCount.py.

👉 No.1 This time, when the program runs, the output should looks much cleaner, with the keys sorted.

{' ': 13,
 ',': 1,
 '.': 1,
 'A': 1,
 'I': 1,
 'a': 4,
 'b': 1,
 'c': 3,
 'd': 3,
 'e': 5,
 'g': 2,
 'h': 3,
 'i': 6,
 'k': 2,
 'l': 3,
 'n': 4,
 'o': 2,
 'p': 1,
 'r': 5,
 's': 3,
 't': 6, 
 'w': 2,
 'y': 1} 

HINT: The pprint.pprint() function is especially helpful when the dictionary itself contains nested lists or dictionaries. If you want to obtain the prettified text as a string value instead of playing it on the screen, call pprint.pformat() instead. These two lines are equivalent to each other: pprint.pprint(someDictionaryValue) print(pprint.pformat(someDictionaryValue))

pretty-character-count's People

Contributors

mullaghori avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.