Python: Input Statements

Post Reply
User avatar
Jason
Site Admin
Posts: 749
Joined: Tue Jul 01, 2025 10:13 am

Code: Select all

try:

	your_car_brand = input("What is your car brand?")

	your_car_age = int(input("What is your car age, in years?"))

	# Input function only accepts strings unless 

	#.there is typecasting

except VaueError:

	return "Please pick an integer."

else:

	print(f"Your car brand is {your_car_brand} and your car age is {your_car_age}.")

 

POSTREACT(ions) SUMMARY

Post Reply