小编nit*_*irl的帖子

如何循环回到程序的开头 - Python

我用 python 3.4 编写了一个 BMI 计算器,最后我想询问用户是否愿意再次使用该计算器,如果是,请返回到代码的开头。到目前为止我已经得到了这个。非常欢迎任何帮助:-)

#Asks if the user would like to use the calculator again
again =input("Thank you again for using this calculator, would you like to try again? Please type y for yes or n for no-")

while(again != "n") and (again != "y"):
    again =input("Please type a valid response. Would you like to try again? Please type y for yes or n for no-")

if again == "n" :
    print("Thank you, bye!")

elif again == "y" …
Run Code Online (Sandbox Code Playgroud)

python loops python-3.x

0
推荐指数
1
解决办法
5万
查看次数

标签 统计

loops ×1

python ×1

python-3.x ×1