1
votes

I just started to learn some coding by using Python.

I couldn't figure out the problem with this code:

num = input("Enter the number for 'num': ")
N = input("Enter the number for 'N': ")

if num.isdigit() and N.isdigit():
    num = int(num)
    N = int(N)
    count = 1
    while count <= N:
        print("{1} * {2} = {3}".format(count, num, count * num)
        count += 1
else:
    print("Invalid input")

It suggested that there is a syntax error in line 10:

File "program.py", line 10
count += 1
    ^
SyntaxError: invalid syntax
1
Missing parentheses at the end: print("{1} * {2} = {3}".format(count,num,count*num) change to print("{1} * {2} = {3}".format(count,num,count*num)) - idjaw

1 Answers

11
votes

The syntax error is in the line before. You forgot the closing parenthesis in your call to print.

Rule of thumb: weird syntax error: look at the line above.