3. Placeholders with numbers
Date and time
Padding and Alignment


Great! In the previous exercise, we used empty placeholders, or {}. We can also put indices inside the placeholders to indicate which value we want to insert into the given placeholder:

user_age = 25
user_name = 'Kate'
user_location = 'Brazil'

greeting = 'Hello, {0}! You are {1}. Welcome to {2}! Farewell, {0}!'.format(user_name, user_age, user_location)

Result: Hello, Kate! You are 25. Welcome to Brazil! Farewell, Kate!

Value indices start at 0 and are indexed from left to right, so {0} = user_name, {1} = user_age, and {2} = user_location. By inserting indices, you can use the same value multiple times, just as we did above.


Ask the user for yesterday's weather:

What was the temperature yesterday? 

Then, ask for today's weather:

What is the temperature today? 

Finally, ask for their city name:

What city are you in? 

Then, write the following:

The temperature in {city} yesterday was {x}. The temperature in {city} today is {y}. The 2-day mean temperature is {(x+y)/2}.

Notice: you need to cast user input values to integers before subtracting the amount spent from the amount earned.

Stuck? Here's a hint!

You need to show the city name twice, so it's a good idea to use placeholders with numbers.

Example inputs:

temp_yesterday = 12
temp_today = 13
city = 'New York'


The temperature in New York yesterday was 12. The temperature in New York today is 13. The 2-day mean temperature is 12.5.