question = input("Would you like to multiply two numbers together?") #asking question here
if question.upper() == "YES": #makes sure that user input is correctly taken into account
FirstNumber = eval(input("please enter your first number?")) # turns string into a number
SecondNumber = eval(input("please enter your second number?")) #same here
result = FirstNumber * SecondNumber # calculates the product of the two variables
if result <= 1000:
print("the result was greater than a 1000!" #checks if the result is less than or equal to 1000
else:
print('The result is ', result) # this is the line that I have trouble with
else:
print(":((((((((((((((((((((")
This program multiplies two numbers together if the result is greater than, or equal to, 1000.
CodePudding user response:
Try changing this line
print("the result was greater than a 1000!" #checks if the result is less than or equal to 1000
into this
print("the result was greater than a 1000!") #checks if the result is less than or equal to 1000
missing paranthesis
CodePudding user response:
question = input("Would you like to multiply two numbers together?") #asking question here
if question.upper() == "YES": #makes sure that user input is correctly taken into account
FirstNumber = eval(input("please enter your first number?")) # turns string into a number
SecondNumber = eval(input("please enter your second number?")) #same here
result = FirstNumber * SecondNumber # calculates the product of the two variables
# FIX: '<' is replaced by '>'
if result >= 1000:
# FIX: add ')'
print("the result was greater than a 1000!") #checks if the result is less than or equal to 1000
else:
print('The result is ', result) # this is the line that I have trouble with
else:
print(":((((((((((((((((((((")
CodePudding user response:
It's actually line 10 that gives you the error. It would be helpful in the future to include the Error as displayed in console in your post/question. You're missing a closing parentheses at:
print("the result was greater than a 1000!"
Also your logic is off. You want it to print print("the result was greater than a 1000!")
, but yet, you have it go to that when the result is less than or equal 10 1000.
Your code should be:
question = input("Would you like to multiply two numbers together? ") #asking question here
if question.upper() == "YES": #makes sure that user input is correctly taken into account
FirstNumber = eval(input("please enter your first number? ")) # turns string into a number
SecondNumber = eval(input("please enter your second number? ")) #same here
result = FirstNumber * SecondNumber # calculates the product of the two variables
if result > 1000:
print("the result was greater than a 1000!") #checks if the result is less than or equal to 1000
else:
print('The result is ', result) # this is the line that I have trouble with
else:
print(":((((((((((((((((((((")