Skip to content

Instantly share code, notes, and snippets.

@azdafirmansyah
Last active November 22, 2017 07:45
Show Gist options
  • Save azdafirmansyah/faf65568625c08313d08fbe06963c48d to your computer and use it in GitHub Desktop.
Save azdafirmansyah/faf65568625c08313d08fbe06963c48d to your computer and use it in GitHub Desktop.
Challenge - Character Input
#Create a program that asks the user to enter their name and their age.
#Print out a message addressed to them that tells them the year that they will turn 100 years old.
from datetime import datetime
current_year = datetime.now().year
while True:
try:
name = str(input("Name :"))
if len(name) == 0:
print("Please input name")
else:
print("your name is :",name)
age = int(input("Age :"))
if age > 0:
print("Age is : ", age)
temp = 100 - age
result = temp + int(current_year)
print("You become 100 at :",result)
else:
print("please input age")
except Exception as e:
print("Please Check Your Input ",e)
finally:
print("--------------------")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment