Can someone tell me if I did this right (TL3 note: possible school assignment)

# Given number1=8 and number2=13 write a program to only displays if the sum is less than 10.

num1 = int(input("Enter your number "))
num2 = int(input("Enter your number "))
sum = "num1 + num2 == 10"
if num1 + num2 > 10:
	print("This is greater than 10")
else:
	print("This is less than 10")

I don’t understand why you have this string here.

So I don’t need to have that to add them together?

https://replit.com/@doxr/JumboSturdyHypothesis

I don’t know much Python but I got some errors.

num1 = int(input("Enter your number "))
num2 = int(input("Enter your number "))
# sum = num1 + num2 == 10 Removed this
if num1 + num2 > 10:
  print("This is greater than 10")
else:
  print("This is less than 10")

is my fixed version. I removed what @anon40284853 said.

doesn’t seem to work, I don’t really know why. I used " instead

1 Like

uhh looks like

if num1 + num2 does the job. Also, you made sum but you never really used it…

Ok, thank you so much you are awesome.

That can’t add them together. That is a string and as such is just text with no calculations. Also == is used for comparison, not assigning a variable.

2 Likes

Looks like a school assignment. Next time don’t just give the answer.

2 Likes

They did all the work and asked if it works. I don’t know much python but the errors told me what to fix on Replit. I didn’t code it, they did. After that, I don’t think there is a problem but that’s just my opinion.

Besides, I don’t know the answer (lol i don’t code in python)

I honestly entirely disagree. You should let the student debug on their own.

2 Likes

Thank you all, I’m new to python and I appreciate the help. ; )

1 Like