Mar-26-2020, 11:55 PM
For the formatting, I first made a function to find which toys' name has the most letters and how many that is. Then I recorded the largest for each. Finally, I went through the cost for each and printed it out. This could definitely be done more smoothly with the help of dictionaries and possibly more functions, which I would suggest to work on. Anyway, here's the code.
def LargestCharacterCount(WordList): count = 0 for word in WordList: if len(str(word)) > count: count = len(str(word)) return count toys = ("Teddy Bear","Toy Train","Hoola Hoop","Betsy Wetsy","Pogo stick") costs = (12.50,58.75,10.00,15.00,11.00) markup = () for cost in costs: markup += (cost*.4, ) LargestToyCharacterAmount = LargestCharacterCount(toys) LargestCostCharacterAmount = LargestCharacterCount(costs) LargestMarkupCharacterAmount = LargestCharacterCount(markup) count = 0 print("Item", " "*(LargestToyCharacterAmount-4), "Cost", " "*(LargestCostCharacterAmount-4), "Markup", " "*(LargestMarkupCharacterAmount-6), "Retail") for toy in toys: print(toy, " "*(LargestToyCharacterAmount-len(toy)), costs[count], " "*(LargestCostCharacterAmount-len(str(costs[count]))), markup[count], " "*(LargestMarkupCharacterAmount-len(str(markup[count]))), costs[count]+markup[count]) count += 1