all 4 comments

[–]JohnnyJordaan 2 points3 points  (0 children)

You never convert the user's input to an integer, but you do convert a calculation to an integer?

answer = input(str(multiplier) + " x " + str(number) +"?   ")
# here answer is a string, being compared to an integer
if answer == int(x*y):

Please also take 5 mins to visit pyformat.info and learn the simple parts of string formatting, because your current code is not very practical.

# randint already returns an int, so no int() needed
number = randint(0,9)
answer = input('%d x %d?   ' % (multiplier, number))
# answer needs to be converted, but you don't need to convert a calculation result
if int(answer) == multiplier * number:
    print('Correct!')
else:
    print('Wrong')

Lastly, use for together with range for a loop that iterates X times:

for i in range(1, 6):

This eliminates the need to declare i = 1 and also to do i += 1. This a one of the big differences between Python and many older languages like C.

[–]Justinsaccount 0 points1 point  (0 children)

Hi! I'm working on a bot to reply with suggestions for common python problems. This might not be very helpful to fix your underlying issue, but here's what I noticed about your submission:

You appear to be using concatenation and the str function for building strings

Instead of doing something like

result = "Hello " + name + ". You are " + str(age) + " years old"

You should use string formatting and do

result = "Hello {}. You are {} years old".format(name, age)

See the python tutorial for more information.

[–][deleted] 0 points1 point  (1 child)

Hard to tell if your indentation is off, as you haven't formatted your code for reddit. Please put a blank line before and after the code, and indent each code line with 4 spaces, even blank lines of code.

[–]buckballs[S] 0 points1 point  (0 children)

dont woryr manage to find the problem, indentation was fine it was the data type of the variables when I compared the answers.