首页 > 解决方案 > 似乎无法让这个程序在 bash 中打印输出

问题描述

因此,当我在 sublime ctrl-b 上运行它时,我得到以下输出:

2
this is a example string with a _x_
ok so you have 3 left
What is your guess?

但是,当我在 git-bash 中运行它时,它只是运行,没有错误,没有输出,没有用户输入请求。我是新手,这只是我正在做的学校测验的一小部分。有什么建议么?

string1 = "this is a example string with a _x_"
sample_list = [1, 2, 3]

def main():
    print (sample_list[1])
    print (string1)
    chances = 3
    while chances > 0:
        print ("ok so you have " + str(chances) + " left")
        answer = input("What is your guess?")
        if answer == sample_list[0]:
            print ("Great, here is your new string!")
            print (string1.replace('_x_', str(sample_list[1])))
        elif answer != sample_list[1]:
            print ("Aw Schucks")
        chances -= 1
    print ("Out of chances")

main()

标签: pythonpython-3.xfunctiongit-bash

解决方案


推荐阅读