I am trying to convert input() data to int() with the following code:
prompt_text = \"Enter a number: \"
try:
user_num = int(input(prompt_text))
except ValueEr
This may not be the cleanest solution but it addresses the problem, in your code user_num is not initialized unless it is a number.
prompt_text = "Enter a number: "
user_num = "no Input"
try:
user_num = int(input(prompt_text))
except ValueError:
print("Error")
if str(user_num).isnumeric():
for i in range(1,10):
print(i, " times ", user_num, " is ", i*user_num)
even = ((user_num % 2) == 0)
if even:
print(user_num, " is even")
else:
print(user_num, " is odd")
else:
print("You did not enter a number")