diff options
| author | Paulo Custodio <pauloscustodio@gmail.com> | 2021-12-23 14:33:04 +0000 |
|---|---|---|
| committer | Paulo Custodio <pauloscustodio@gmail.com> | 2021-12-23 14:33:04 +0000 |
| commit | ce5bd2dd1a3159107febe4b9eb488a071bc601f5 (patch) | |
| tree | fe414d6bf26de2b2c6682c2b399ace41a24492cf /challenge-032/paulo-custodio/python/ch-2.py | |
| parent | 9f83fe38e24a005d07ee31c0c53582f3eefbc9e5 (diff) | |
| download | perlweeklychallenge-club-ce5bd2dd1a3159107febe4b9eb488a071bc601f5.tar.gz perlweeklychallenge-club-ce5bd2dd1a3159107febe4b9eb488a071bc601f5.tar.bz2 perlweeklychallenge-club-ce5bd2dd1a3159107febe4b9eb488a071bc601f5.zip | |
Whitespace
Diffstat (limited to 'challenge-032/paulo-custodio/python/ch-2.py')
| -rw-r--r-- | challenge-032/paulo-custodio/python/ch-2.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/challenge-032/paulo-custodio/python/ch-2.py b/challenge-032/paulo-custodio/python/ch-2.py index e8956935b6..6a0b7385c7 100644 --- a/challenge-032/paulo-custodio/python/ch-2.py +++ b/challenge-032/paulo-custodio/python/ch-2.py @@ -8,13 +8,13 @@ # Write a function that takes a hashref where the keys are labels and the # values are integer or floating point values. Generate a bar graph of the # data and display it to stdout. -# +# # The input could be something like: -# +# # $data = { apple => 3, cherry => 2, banana => 1 }; # generate_bar_graph($data); # And would then generate something like this: -# +# # apple | ############ # cherry | ######## # banana | #### @@ -25,10 +25,10 @@ data = { 'apple':3, 'cherry':2, 'banana':1 } def chart(data): - # get size of keys + # get size of keys width = max([len(x) for x in data]) - # output data + # output data for key in sorted(data): print(("{:"+str(width)+"s} | {}").format(key, "##"*data[key])) |
