SyntaxError:无效语法(非常简单的一个) [英] SyntaxError: invalid syntax (very simple one)

查看:80
本文介绍了SyntaxError:无效语法(非常简单的一个)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用 Python 学习一些编码.

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")

提示第 10 行有语法错误:

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

File "program.py", line 10
count += 1
    ^
SyntaxError: invalid syntax

推荐答案

语法错误在前一行.您忘记了调用 print 时的右括号.

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.

这篇关于SyntaxError:无效语法(非常简单的一个)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆