Mar-26-2020, 05:26 PM
So the most letters from a month is 9, so I just put extra spaces in between the month and stars based on how many letters were in that month. For example in June, there are an extra 5 spaces. You can take a look at the code below.
#Variable List # months - the tuple for months # sales - the corresponding sales for each month print ("Welcome to the Artic Dog program") #step 1 - this will create a tuple for the months and sales months = ("January","February","March","April","May","June","July","August","September","October","November","December") sales = (28,30,24,10,12,10,5,3,4,10,21,25) # step 3 - this will print and format the months and bar graph total = 0 count = 0 for item in months: print (item," "*(9-len(item)), "{:<30}".format(sales[count]*"*")) count = count + 1 for num in sales: total = num + total print ("Total Sold for 20XX","{:<30}".format(total))