Feb-23-2018, 06:30 PM
import random
def function1():
a = random.randint(1,50)
b = random.randint(1,50)
c = a + b
print('what is',a,'plus',b,'?')
d = input()
if d > c:
print('your answer was incorrect, its a little too big')
if d < c:
print('your answer was incorrect, its a little higher')
else:
print('your answer was correct')
I just started coding and I dont understand whats wrong with this piece of code, whenever I try to execute the function, it says
'>' not supported between instances of 'str' and 'int'
but its a integer because I entered a number right? how do I fix this guys
def function1():
a = random.randint(1,50)
b = random.randint(1,50)
c = a + b
print('what is',a,'plus',b,'?')
d = input()
if d > c:
print('your answer was incorrect, its a little too big')
if d < c:
print('your answer was incorrect, its a little higher')
else:
print('your answer was correct')
I just started coding and I dont understand whats wrong with this piece of code, whenever I try to execute the function, it says
'>' not supported between instances of 'str' and 'int'
but its a integer because I entered a number right? how do I fix this guys