python - 上次运行代码在启动代码时出现问题,因为缩进块
问题描述
我对最后一个代码有问题-“intro()”它阻止我运行代码,所以如果有人能够找出问题所在,那将有很大帮助
*我相信它因为某个地方的错字而无法正常工作,但我无法找到它或修复它,所以我希望你们中的任何人都能发现它并帮助我?
它要求我添加更多细节,但我不能说更多:/
import time
from termcolor import colored, cprint
answer_A = ["A", "a"]
answer_B = ["B", "b"]
answer_C = ["C", "c"]
yes = ["Y", "y", "yes"]
no = ["N", "n", "no"]
phone = 1
Lady_name = 0
Lady_lastname = 0
required = ("\nUse only A, B, or C\n")
print("=========================================================")
def Intro():
print ("\n\n You are sitting at the bar like every friday... ")
time.sleep(2)
print ("\n After your wife passed away, you don't really know what to do anymore")
time.sleep(2)
print ("\n You see a lady looking at you in the cornor of your eye.")
time.sleep(2)
print("""\n A. Move over and talk to the lady .
B. Let the lady be, she probably thinks you are weird.""")
choice = input(">>> ")
if choice in answer_A:
time.sleep(1)
option_lady()
elif choice in answer_B:
print("\n You let the lady be... \n You have been sitting here a while now and the lady have been glancing over at me the whole time.")
time.sleep(3)
print ("\n You glance over at her wondering if she is watching you.")
time.sleep(2)
print ("\n You make eye contact")
time.sleep(1)
print("""\n A. Go and talk to the lady.
B. Go home for the night.""")
choice = input(">>> ")
if choice in answer_A:
option_lady()
elif choice in answer_B:
print("\n You go and home and the lady looks sad. \n\n You go to sleep and never wake up again...")
def option_lady():
print ("\n you walk over to the lady")
print("""\n A. Hey, how you doing?
B. Hey, whats your name?""")
choice = input(">>> ")
if choice in answer_A:
option_question
elif choice in answer_B:
Lady_name = 1
Lady_lastname = 1
print ("\n Hey, Whats your name? You say.")
time.sleep(1)
cprint ('\nTracey! My name is Tracey smith.', 'red')
time.sleep(1)
Lady_name = 1
Lady_lastname = 1
print("\nWhat are you gonna answer? ")
print("""\n A. How are you doing?
\nB. Can I buy you a drink?""")
choice = input (">>> ")
if choice in answer_A:
print("dsa")
elif choice in answer_B:
Intro()
'
解决方案
您的代码以elif choice in answer_B:
. 任何以结尾的语句都:
必须有一个主体,一些代码。如果您明确不想在那里放任何东西,pythonpass
正是出于这个原因提供的:
elif choice in answer_B:
pass
应该修复它。
推荐阅读
- macos - 我成功地使用 curl 代码将文本下载到 Visual Studio 代码中。有没有办法重定向它并将其保存为文本文件?
- c - 如何运行此文本文件并使用 strtok() 提取数字并将数字存储在不同的文件中?
- c++ - 获取函数不适用于虚方法
- angular - 如何使用角度材料放置内联 div?
- javascript - 使用 requestAnimationFrame 重复的 3 秒动画
- python - Tensorflow 错误:不支持的可调用 - (来自 ex ???)
- javascript - 动态生成 TinyMCE 下拉菜单
- java - 如何从 Spring Boot 测试中启用嵌入式 MongoDB 中的日志
- spring - 将 Spring 数据源传递给 Javers 以审核 DTO
- javascript - 在 JavaScript 中使用 for 循环绘制 Canvas 的问题