Python 为相应数量的字母打印下划线

Python 为相应数量的字母打印下划线,python,Python,我试着把刽子手的答案打印出来,打印出和刽子手的答案一样多的下划线。我试着把它放进去 for letters in range(wordChoice): print("_") 但是,这只会在下一行打印一个下划线。我也试过了 print("_", * wordChoice) 这告诉我单词选择并没有定义。下面是没有我尝试的原始代码 def WordChoice(): wordChoice = input("Pleas

我试着把刽子手的答案打印出来,打印出和刽子手的答案一样多的下划线。我试着把它放进去

for letters in range(wordChoice):

        print("_")
但是,这只会在下一行打印一个下划线。我也试过了


print("_", * wordChoice)

这告诉我单词选择并没有定义。下面是没有我尝试的原始代码

def WordChoice():

    wordChoice = input("Please Enter The Answer Of Choice:\n>>> ")
    
    print("You Entered:\n>>> ", wordChoice)
    print(list(wordChoice))
    
    playerConfirmation = int(input("If Correct, Enter 1\nIf Not Correct, Enter 2:\n>>> "))

    correct = 1

    if playerConfirmation == correct:

        print("Answer Has Been Stored! Please Pass Keyboard To Player 1!")

    else:

        WordChoice()

道歉@PranavHosangadi我编辑了我的postSolutiond:我通过询问discord找到的解决方案是用wordChoice:print(“”,end=“”)打印字母的