我是靠谱客的博主 潇洒咖啡豆,最近开发中收集的这篇文章主要介绍pythonfor循环if中断怎么使用_python在for循环中中断if语句,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

试试这个:def pTurn(CampLoc, AICampLoc, score, yourHits, cHits):

if yourHits < 5:

#^This line ident is probably the offending line. ;)

hGuess = int(raw_input("Enter a co-ordinate to air-strike: "))

print "Air-striking co-ordinate: %d" % hGuess

for cSpot in AICampLoc:

if hGuess == cSpot:

yConfirMsg = "Kill confirmed!!"

yourHits += 1

score += 100

AICampLoc.remove(hGuess)

break

else:

yConfirMsg= "No casualties"

score = score #You may want to fix this, since the logic doesn't make sense

yourHits = yourHits #Fix this line as well. This is variable value assignment to the same variable.

如果这不起作用,另一件要考虑的事情是,在缩进代码的前导空格时,可能会无意中混合使用制表符和空白。如果是,请将所有选项卡转换为空格。

关于引用的注释。也许你是想回报那些价值观?如果是的话,你需要修

最后

以上就是潇洒咖啡豆为你收集整理的pythonfor循环if中断怎么使用_python在for循环中中断if语句的全部内容,希望文章能够帮你解决pythonfor循环if中断怎么使用_python在for循环中中断if语句所遇到的程序开发问题。

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

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

评论列表共有 0 条评论

立即
投稿
返回
顶部