I have written this program which asks the user about how many rectangles they wants to print out. It also asks for the width and height of each, and prints the triangles. After asking the height and width of each, it moves onto the next rectangle and so on.
This all works fine using the program I've made but at the end I want to print out the total area of all the rectangles that the user has created. How can I update my code and achieve this? How is it possible to store the area of the first rectangle and add the area of the second to this first area and so on? Here is the code:
size = input("How many rectangles?" ) #asks the number of rectangles
i=1
n = 1
while i <= size:
w = input("Width "+str(n)+"? ") #asks for width of each rectangle
h = input("Height "+str(n)+"? ") #asks for height of each rectangle
n=n+1
h1=1
w1=1
z = ""
while w1 <= w:
z=z+"*"
w1+=1
while h1<=h:
print z
h1+=1
i+=1