I wrote a simple map() function that iterates over a list and prints as many '*' that are in the list. I see a small problem with my code, I see an extra 'None'
in my output. Could someone help me debug this issue?
Problem Statement:
-----------------
Define a procedure histogram() that takes a list of integers and prints a
histogram to the screen. For example, histogram([4, 9, 7]) should print the
following:
****
*********
*******
Source Code
def print_asterisks(num):
print ''.join('*' for i in xrange(num))
def histogram(s):
map(print_asterisks, s)
def main():
# Test inputs
print histogram([4,7,5])
if __name__ == "__main__":
import sys
sys.exit(main())
Output
****
*******
*****
None