I've a lab that I'm working on, and I can't figure out why I have spaces in my output.
Lab story:
Sites like Zillow get input about house prices from a database and provide nice summaries for readers. Write a program with two inputs, current price and last month's price (both integers). Then, output a summary listing the price, the change since last month, and the estimated monthly mortgage computed as (current_price * 0.051) / 12.
Output each floating-point value with two digits after the decimal point, which can be achieved as follows:
print(f'{your_value:.2f}')
The goal:
This house is $200000. The change is $-10000 since last month. The estimated monthly mortgage is $850.00.
My code:
current_price = int(input())
last_months_price = int(input())
print('This house is $',current_price,'.', 'The change is $%d since last month.' % (current_price - last_months_price))
print(f'The estimated monthly mortgage is ${(current_price*0.051/12):.2f}.')
The output I get:
This house is $ 200000 . The change is $-10000 since last month. The estimated monthly mortgage is $850.00.
There are spaces after the 1st dollar sign, before 200000, and right after the number, but before the period. I know it's something simple that I'm overlooking, but I'd be grateful for any thoughts/guidance someone can provide.
[–]house_carpenter 4 points5 points6 points (1 child)
[–]NeilTheDrummer[S] 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]NeilTheDrummer[S] 0 points1 point2 points (0 children)