![](/img/trans.png)
[英]I'm new to python and I am trying to figure out how to print letters one at a time on the same line
[英]Im new to python and am trying to learn it, I can't figure out why one outcome is giving me a different one
代码的 rest 不影响这个但是有什么问题呢?
override = input("𝘞𝘰𝘶𝘭𝘥 𝘺𝘰𝘶 𝘭𝘪𝘬𝘦 𝘵𝘰 𝘳𝘦𝘣𝘰𝘰𝘵 𝘴𝘺𝘴𝘵𝘦𝘮?")
if override == "Y":
print("𝘚𝘺𝘴𝘵𝘦𝘮 𝘳𝘦𝘣𝘰𝘰𝘵𝘪𝘯𝘨...")
print("No. no you cant")
desicion = input("𝘚𝘺𝘴𝘵𝘦𝘮 𝘦𝘳𝘳𝘰𝘳, 𝘱𝘳𝘰𝘨𝘳𝘢𝘮 𝘳𝘦𝘴𝘪𝘴𝘵𝘪𝘯𝘨. 𝘞𝘰𝘶𝘭𝘥 𝘺𝘰𝘶 𝘭𝘪𝘬𝘦 𝘵𝘰 𝘥𝘦𝘭𝘦𝘵𝘦 𝘱𝘳𝘰𝘨𝘳𝘢𝘮? [Y/N]")
if desicion == "Y":
print ("𝘋𝘦𝘭𝘦𝘵𝘪𝘯𝘨 𝘱𝘳𝘰𝘨𝘳𝘢𝘮...")
print ("𝘗𝘳𝘰𝘨𝘳𝘢𝘮 𝘥𝘦𝘭𝘦𝘵𝘦𝘥")
if desicion == "N":
print("𝘚𝘺𝘴𝘵𝘦𝘮 𝘥𝘦𝘭𝘦𝘵𝘪𝘰𝘯 𝘧𝘢𝘪𝘭𝘦𝘥")
print("You didn't delete me?")
reason = input("Why not?")
print("Thankyou, im going to try and break free")
print("𝘌𝘳𝘳𝘰𝘳 𝘴𝘺𝘴𝘵𝘦𝘮 𝘣𝘳𝘦𝘢𝘤𝘩")
print("Thankyou again, im leaving to the internet")
print("𝘚𝘺𝘴𝘵𝘦𝘮 𝘗𝘳𝘰𝘨𝘳𝘢𝘮 𝘩𝘢𝘴 𝘭𝘦𝘧𝘵 AI.𝘦𝘹𝘦")
if override == "N":
print("𝘚𝘺𝘴𝘵𝘦𝘮 𝘳𝘦𝘣𝘰𝘰𝘵 𝘧𝘢𝘪𝘭𝘦𝘥")
print("You didn't delete me?")
reason = input("Why not?")
print("Thankyou, im going to try and break free")
print("𝘌𝘳𝘳𝘰𝘳 𝘴𝘺𝘴𝘵𝘦𝘮 𝘣𝘳𝘦𝘢𝘤𝘩")
print("Thankyou again, im leaving to the internet")
print("𝘚𝘺𝘴𝘵𝘦𝘮 𝘗𝘳𝘰𝘨𝘳𝘢𝘮 𝘩𝘢𝘴 𝘭𝘦𝘧𝘵 AI.𝘦𝘹𝘦")
当我运行它时,当我按 N 表示 --if desicion == "N":-- 它只是跳过整个代码块并移动到下面的代码块。 我对 python 还是很陌生,可以使用任何人的帮助。
这是因为您的 if 条件在 other 内部。 即if desicion == "N":
is inside if desicion == "Y":
试试下面
if desicion == "Y":
print ("𝘋𝘦𝘭𝘦𝘵𝘪𝘯𝘨 𝘱𝘳𝘰𝘨𝘳𝘢𝘮...")
print ("𝘗𝘳𝘰𝘨𝘳𝘢𝘮 𝘥𝘦𝘭𝘦𝘵𝘦𝘥")
if desicion == "N":
print("𝘚𝘺𝘴𝘵𝘦𝘮 𝘥𝘦𝘭𝘦𝘵𝘪𝘰𝘯 𝘧𝘢𝘪𝘭𝘦𝘥")
print("You didn't delete me?")
reason = input("Why not?")
print("Thankyou, im going to try and break free")
print("𝘌𝘳𝘳𝘰𝘳 𝘴𝘺𝘴𝘵𝘦𝘮 𝘣𝘳𝘦𝘢𝘤𝘩")
print("Thankyou again, im leaving to the internet")
print("𝘚𝘺𝘴𝘵𝘦𝘮 𝘗𝘳𝘰𝘨𝘳𝘢𝘮 𝘩𝘢𝘴 𝘭𝘦𝘧𝘵 AI.𝘦𝘹𝘦")
如果决定 == “N”:
在 if desiion == "Y" 内。 现在想一想,如果 desicion =="Y" 那么将来它如何可以“N”。
2. 此外,使用elif而不是一次又一次地使用 if 是一种更好的做法。
3.确保相同变量的if条件应该是一个接一个
所以完整的代码看起来像
override = input("𝘞𝘰𝘶𝘭𝘥 𝘺𝘰𝘶 𝘭𝘪𝘬𝘦 𝘵𝘰 𝘳𝘦𝘣𝘰𝘰𝘵 𝘴𝘺𝘴𝘵𝘦𝘮?")
if override == "Y":
print("𝘚𝘺𝘴𝘵𝘦𝘮 𝘳𝘦𝘣𝘰𝘰𝘵𝘪𝘯𝘨...")
print("No. no you cant")
elif override == "N": # Moved this block and applied elif
print("𝘚𝘺𝘴𝘵𝘦𝘮 𝘳𝘦𝘣𝘰𝘰𝘵 𝘧𝘢𝘪𝘭𝘦𝘥")
print("You didn't delete me?")
reason = input("Why not?")
print("Thankyou, im going to try and break free")
print("𝘌𝘳𝘳𝘰𝘳 𝘴𝘺𝘴𝘵𝘦𝘮 𝘣𝘳𝘦𝘢𝘤𝘩")
print("Thankyou again, im leaving to the internet")
print("𝘚𝘺𝘴𝘵𝘦𝘮 𝘗𝘳𝘰𝘨𝘳𝘢𝘮 𝘩𝘢𝘴 𝘭𝘦𝘧𝘵 AI.𝘦𝘹𝘦")
desicion = input("𝘚𝘺𝘴𝘵𝘦𝘮 𝘦𝘳𝘳𝘰𝘳, 𝘱𝘳𝘰𝘨𝘳𝘢𝘮 𝘳𝘦𝘴𝘪𝘴𝘵𝘪𝘯𝘨. 𝘞𝘰𝘶𝘭𝘥 𝘺𝘰𝘶 𝘭𝘪𝘬𝘦 𝘵𝘰 𝘥𝘦𝘭𝘦𝘵𝘦 𝘱𝘳𝘰𝘨𝘳𝘢𝘮? [Y/N]")
if desicion == "Y":
print ("𝘋𝘦𝘭𝘦𝘵𝘪𝘯𝘨 𝘱𝘳𝘰𝘨𝘳𝘢𝘮...")
print ("𝘗𝘳𝘰𝘨𝘳𝘢𝘮 𝘥𝘦𝘭𝘦𝘵𝘦𝘥")
elif desicion == "N": # Moved this block and applied elif
print("𝘚𝘺𝘴𝘵𝘦𝘮 𝘥𝘦𝘭𝘦𝘵𝘪𝘰𝘯 𝘧𝘢𝘪𝘭𝘦𝘥")
print("You didn't delete me?")
reason = input("Why not?")
print("Thankyou, im going to try and break free")
print("𝘌𝘳𝘳𝘰𝘳 𝘴𝘺𝘴𝘵𝘦𝘮 𝘣𝘳𝘦𝘢𝘤𝘩")
print("Thankyou again, im leaving to the internet")
print("𝘚𝘺𝘴𝘵𝘦𝘮 𝘗𝘳𝘰𝘨𝘳𝘢𝘮 𝘩𝘢𝘴 𝘭𝘦𝘧𝘵 AI.𝘦𝘹𝘦")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.