如何解决python中的文件“ <stdin>”错误?

时间:2020-04-29 14:46:24

标签: python stdin

我收到此错误:

File "<stdin>", line 2
    print("hello " + friend)
        ^
IndentationError: expected an indented block

在python中的简单代码。我尝试检查语法,但没有发现任何错误。这是代码:

friends = ["a", "b", "c", "d"]
for friend in range(friends):
print("hello "+friend)

1 个答案:

答案 0 :(得分:1)

使用此

friends = ["a", "b", "c", "d"]
for friend in friends:
    print("hello "+friend)

为您提供以下内容

你好 你好乙 你好ç 你好d

output