Python 缩进错误1

Python 缩进错误1,python,indentation,Python,Indentation,我不知道为什么会有一个凹痕区域,但它确实让我感到压力很大 print "hello!" print "I\'m Charlie and I\'m going to test the security of your password!" print "first I\'d like to know a bit about you! What is your name? (No data is stored!!)" name = raw_input() print "Nice to meet yo

我不知道为什么会有一个凹痕区域,但它确实让我感到压力很大

print "hello!"
print "I\'m Charlie and I\'m going to test the security of your password!"
print "first I\'d like to know a bit about you! What is your name? (No data is stored!!)"
name = raw_input()
print "Nice to meet you, %s!" % (name)
print "What is your date of birth?"
dob = raw_input()
print "OK! Those answers are used to help me but are forgotten when you close the window!"
print "Now %s, are you ready for your password to be tested?" % (name)
    if raw_input() = "yes"
        print "what is your password?"
    if raw_input() = "no"
        print "Suit yourself, %s!" % (name)

你的程序有很多问题,所以我强烈建议你学习一些教程

print "hello!"
print "I\'m Charlie and I\'m going to test the security of your password!"
print "first I\'d like to know a bit about you! What is your name? (No data is stored!!)"
name = raw_input()
print "Nice to meet you, %s!" % (name)
print "What is your date of birth?"
dob = raw_input()
print "OK! Those answers are used to help me but are forgotten when you close the window!"
yes_no = raw_input("Now %s, are you ready for your password to be tested?" % (name))
if yes_no.lower() == 'yes':
    print "what is your password?"
if yes_no.lower() == "no":
    print "Suit yourself, %s!" % (name)
始终将
原始\u输入分配给变量

例: 更改此
print“首先,我想了解一下你!你叫什么名字?(没有存储数据!!)”

为此:

name = raw_input("first I\'d like to know a bit about you! What is your name? (No data is stored!!)"
其次

当您使用
if
for
while
等语句时,必须以
结束语句,并且只要您的条件保持为真,您想要执行的任何语句都应该缩进

例:


这样,程序的布局对用户来说会更加清晰。查看一些教程并试用它们

首先,当您编写
if
语句时,缩进已关闭。您需要在一个选项卡空间内将它们带回来

以下是工作代码的示例:

print "hello!"
print "I\'m Charlie and I\'m going to test the security of your password!"

print "first I\'d like to know a bit about you! What is your name? (No data is stored!!)"
name = raw_input()
print "Nice to meet you, %s!" % (name)

print "What is your date of birth?"
dob = raw_input()

print "OK! Those answers are used to help me but are forgotten when you close the window!"
print "Now %s, are you ready for your password to be tested?" % (name)

# I fixed the indentation below:

if raw_input() == "yes": #<-- fixed comparison operator here and added colon
    print "what is your password?"
if raw_input() == "no": #<-- fixed comparison operator here and added colon
    print "Suit yourself, %s!" % (name)
打印“你好!”
打印“我是查理,我要测试你密码的安全性!”
打印“首先我想了解一下你!你叫什么名字?(没有存储数据!!)”
名称=原始输入()
打印“很高兴认识你,%s!”%(姓名)
打印“你的出生日期是什么?”
dob=原始输入()
打印“好的!这些答案是用来帮助我的,但是当你关上窗户的时候就被忘记了!”
打印“现在%s,您准备好测试密码了吗?”%(名称)
#我修正了下面的缩进:

如果raw_input()=“yes”:#多亏了Josh B.letsc,我现在已经完成了代码:

print "hello!"
print "I\'m Charlie and I\'m going to test the security of your password!"
print "first I\'d like to know a bit about you! What is your name? (No data is stored!!)"
name = raw_input()
print "Nice to meet you, %s!" % (name)
print "What is your date of birth?"
dob = raw_input()
print "OK! Those answers are used to help me but are forgotten when you close the window!"
yes_no = raw_input("Now %s, are you ready for your password to be tested?" % (name))
if yes_no.lower() == 'yes':
    print "what is your password?"
    passw = raw_input()
    if passw == "password":
       print "really? You\'ve got to be kidding me!"
    if passw == name:
        print "Anybody who knows your name will be able to guess that!"
    if passw == dob:
        print "Anyone who knows your birthday can guess that!"
    if len(passw) < 5:
        print "That password may not be long enough, %s" % (name)
    if len(passw) > 20:
        print "Are you sure you can remeber that?"
    else:
        print "That\'s a superb password, %s!!" % (name)
if yes_no.lower() == "no":
    print "Suit yourself, %s!" % (name)
打印“你好!”
打印“我是查理,我要测试你密码的安全性!”
打印“首先我想了解一下你!你叫什么名字?(没有存储数据!!)”
名称=原始输入()
打印“很高兴认识你,%s!”%(姓名)
打印“你的出生日期是什么?”
dob=原始输入()
打印“好的!这些答案是用来帮助我的,但是当你关上窗户的时候就被忘记了!”
是\否=原始\输入(“现在是%s,您准备好测试密码了吗?”%(名称))
如果是_no.lower()=“是”:
打印“您的密码是什么?”
passw=原始输入()
如果passw==“密码”:
打印“真的吗?你一定是在跟我开玩笑!”
如果passw==名称:
打印“任何知道你名字的人都能猜到!”
如果passw==dob:
打印“任何知道你生日的人都能猜到!”
如果len(passw)<5:
打印“该密码可能不够长,%s”%(名称)
如果len(passw)>20:
打印“你确定你能记住吗?”
其他:
打印“这是一个极好的密码,%s!!”%(名称)
如果是_no.lower()=“否”:
打印“适合您自己,%s!”%(名称)

将if语句向后拉1个制表符空格。if结尾缺少一个
statements@letsc它仍然不起作用。。。它现在说谢谢我才刚刚开始,所以这可能就是原因@sidneycox-如果这清除了您的错误,请作为我否决的问题的选择答案,因为您的原始答案基本上是“阅读一些教程,这里是工作代码”。现在更容易接受了,downvote撤回了。@letsc我不明白你的意思…@sidneycox别担心,只要你接受(打绿色复选标记)你认为最有用的答案。不过,你只能回答一个问题。谢谢。这是一个很大的帮助!没问题,谢谢你接受我的第一个答案!或者不是…:P无论如何谢谢你@乔希。哈哈,我看到了那里发生的一切,你无能为力。我的第二个答案刚刚被接受并投票支持XD
print "hello!"
print "I\'m Charlie and I\'m going to test the security of your password!"
print "first I\'d like to know a bit about you! What is your name? (No data is stored!!)"
name = raw_input()
print "Nice to meet you, %s!" % (name)
print "What is your date of birth?"
dob = raw_input()
print "OK! Those answers are used to help me but are forgotten when you close the window!"
yes_no = raw_input("Now %s, are you ready for your password to be tested?" % (name))
if yes_no.lower() == 'yes':
    print "what is your password?"
    passw = raw_input()
    if passw == "password":
       print "really? You\'ve got to be kidding me!"
    if passw == name:
        print "Anybody who knows your name will be able to guess that!"
    if passw == dob:
        print "Anyone who knows your birthday can guess that!"
    if len(passw) < 5:
        print "That password may not be long enough, %s" % (name)
    if len(passw) > 20:
        print "Are you sure you can remeber that?"
    else:
        print "That\'s a superb password, %s!!" % (name)
if yes_no.lower() == "no":
    print "Suit yourself, %s!" % (name)