因此,当我在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()