是什么错误:应为扩展块以及如何在程序中修复它?

2024-03-29 08:06:00 发布

您现在位置:Python中文网/ 问答频道 /正文

#my first created softwre
name = 'Tariq'
myPassword = '765%^&'
if name == 'Tariq':
          print('Hi Tariq')
          myPassword = input()
          if myPassword == '765%^&':
          print('Hi creator')
     else:
          print("I don't know you strange")
          input()

它的错误是"expected an indented block"。在

我不知道我该怎么做我试着在引起其他错误的东西之间添加空格,我修正了这些错误,结果我得到了第一个错误。在


Tags: nameinputifmy错误hielsefirst
1条回答
网友
1楼 · 发布于 2024-03-29 08:06:00

这应该可以工作,但可能与您的预期不同:

# my first created software
name = 'Tariq'
my_password = '765%^&'
error = False
if name == 'Tariq':
    print('Hi', name)
    if my_password == '765%^&':
        print('Hi creator')
    else:
        error = True
else:
    error = True
if error:
    print("I don't know you strange")
input()

相关问题 更多 >