Personalized Next Year Age Message

Category: Python Basics

Write a program that asks the user for their name and age, then outputs a message addressing them by their name and telling them how old they will be next year.


Input: Name: John, Age: 25 

Output: "Hi John, you will be 26 years old next year."

Input: Name: Alice, Age: 30 

Output: "Hi Alice, you will be 31 years old next year."

You can use string formatting to insert the user’s name and calculated age into the output message.

name = input("Enter your name: ")
age = int(input("Enter your age: "))
next_year_age = age + 1
print(f"Hi {name}, you will be {next_year_age} years old next year.")

© Let’s Data Science


Unlock AI & Data Science treasures. Log in!