同一行中的两个个性化功能

时间:2019-03-21 21:47:28

标签: python python-3.x string function

我有这个:

import time 
import sys

# Função Linha:

def lin():
   lin = "=" * 30
   for char in lin:
      print(char, end='')
      time.sleep(0.1)

# Função "Acertou!"

def acertou():
    acerto = "Right!"
    for char in acerto:
       print(char, end='')
       time.sleep(0.2)

# Função "Errou!"

  def errou():
     erro = "Wrong!"
     for char in erro:
         print(char, end='')
         time.sleep(0.15)

# Programa Principal

primeira_resposta = "Nitrogen"
primeira_questão = input("What gas makes the sky blue?")

if primeira_questão == primeira_resposta:
    lin()
    acertou()
    lin()

依此类推,我删除了诸如更多问题之类的内容,其中某些内容是葡萄牙语(我是葡萄牙语),我注意到一个错误:lin()函数打印出以下内容:

===============================Right!==============================(next question)

所有内容都在同一行中,如何使我在不同的行中打印lin(),“右”和下一个问题?

1 个答案:

答案 0 :(得分:0)

lin()循环之后,您需要打印新行

def lin():
   lin = "=" * 30
   for char in lin:
      print(char, end='')
      time.sleep(0.1)
   print()

lin()
print()
acertou()  # Next question