python - 似乎无法让这个程序在 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()
解决方案
推荐阅读
- vue.js - Vue 将事件从子级发送到父级
- git - Git:如何不将分支推送到远程
- javascript - 使用 webRTC 获取屏幕列表并选择要在电子中记录的屏幕
- r - 按函数参数过滤 data.tables 列表
- javascript - 使用 PHP 显示数据库中的数据后,CSS 样式和 jquery 添加/删除隐藏类停止工作
- command-line-interface - 如何使用 nim 的 `argparse` 获得可变数量的参数
- here-api - HERE 地图卡车 API
- powershell - 使用 Powershell Resolve-DNS 将 A、CNAME、NS 和 MX 记录的批量 DNS 查询导出为多行而不是 ; 分隔符?
- string - 删除具有两个连续字母的给定字符串的一个字母
- graphql - 如何使用 Apollo 对我的 GraphQL 查询进行重复数据删除?