首页 > 解决方案 > 上次运行代码在启动代码时出现问题,因为缩进块

问题描述

我对最后一个代码有问题-“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()
'

标签: python

解决方案


您的代码以elif choice in answer_B:. 任何以结尾的语句都: 必须有一个主体,一些代码。如果您明确不想在那里放任何东西,pythonpass正是出于这个原因提供的:

   elif choice in answer_B:
     pass

应该修复它。


推荐阅读