I am having trouble trying to figure out how to write code so the room number increases by 1 each time it asks for length and width. Here's what the assignment is about..
In this program, you are going to calculate the total square footage of a five room apartment. (Yes, this is a straightforward count controlled loop problem)
You must use a loop to implement your solution. You can use either a for loop or a while loop.
Here is some sample output:
Please enter length and width of room 1: 10,20
Please enter length and width of room 2: 40,70
Please enter length and width of room 3: 25,40
Please enter length and width of room 4: 15,30
Please enter length and width of room 5: 50,30
The total square footage is 5950
Here is the code I came up with so far:
def main():
sum=0
count=0
x=0
for i in range (5):
x=x+1
l,w=eval(input("Please enter length and width of room"(x)))
sum=sum+(l*w)
count=count+1
print("The total square footage is", sum)
main()
I am a new programmer so any help would be appreciated. Thanks!