i have problem related to break command. i have no idea where to add break
You would use break to exit a loop at one point where a particular condition is met:
odelay_num = raw_input("How many times would you like me to print 'Odelay!' for you? Maximum: 10 Odelays. Don't abuse...") if int(odelay_num) > 10: print "Come on now. I said no abuse! Now shoo!" else: for x in range(0,10): if x == int(odelay_num): print "There you go! Another satisfied customer!" break else: print "Odelay!"
In the battleship game for exemple, the program should stop if the player guess right and succeed in sinking the ship as there is no point of playing anymore if there is no more ship to sink...