我是靠谱客的博主 坚定未来,最近开发中收集的这篇文章主要介绍python文字游戏循环3次_Python第一周_所写代码_练习_三次循环,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

写法一:

age_of_kunpeng = 21

for i in range(3):

guess_age = int(input("guess:"))

if guess_age == age_of_kunpeng:

print("yes , you got it!")

break

elif guess_age > age_of_kunpeng:

print("mybe think smaller...")

else:

print("mybe think bigger,my firend.")

else:

print("you have trried too many times..get fuck off!")

写法二:

age_of_kunpeng = 21

count = 0

while count <3:

guess_age = int(input("guess:"))

if guess_age == age_of_kunpeng:

print("yes , you got it!")

break

elif guess_age > age_of_kunpeng:

print("mybe think smaller...")

else:

print("mybe think bigger,my firend.")

count +=1

else:

print("you have trried too many times..get fuck off!")

方法二:优化(添加了继续流程)

count = 0

while count <3:

guess_age = int(input("guess:"))

if guess_age == age_of_kunpeng:

print("yes , you got it!")

break

elif guess_age > age_of_kunpeng:

print("mybe think smaller...")

else:

print("mybe think bigger,my firend.")

count +=1

if count == 3:

countne_confirm = input("do you want to keep guessing...?")

if countne_confirm != 'n':

count = 0

else:

print("you have trried too many times..get fuck off!")

最后

以上就是坚定未来为你收集整理的python文字游戏循环3次_Python第一周_所写代码_练习_三次循环的全部内容,希望文章能够帮你解决python文字游戏循环3次_Python第一周_所写代码_练习_三次循环所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(64)

评论列表共有 0 条评论

立即
投稿
返回
顶部