#trying to code battleship

16 messages · Page 1 of 1 (latest)

azure swift
#

@royal lintel 🙂

royal lintel
#

In your

if __name__ == "__main__":
     main()
     play_game()

play_game() will run regardless of whatever main() does

#

By convention you should have most logic inside main() in the sense, probably running play_game() from of main() will be the best approach

azure swift
royal lintel
#

No, main() in your case does the following things

  1. Gives instructions
  2. Starts a new game
  3. Displays hall of fame
  4. Quits

For statement 2 you are just breaking out of the function and letting the following function run which isn't conventional correct and leads to errors.

You should instead have play_game() inside of elif num == 2 and have main() as your sole function inside if __name__ statement

azure swift
royal lintel
#

Good luck!

azure swift
royal lintel
#

You're welcome wolfcheer

azure swift
# royal lintel You're welcome <:wolfcheer:861407740564209694>

hi again if you have time to help again i love it if you cant all good 🙂 . im stuck in a infi loop . when i start the code i press "2" play then when i want to exit the game i press "q" this will sent be back to the main menu where then i press "4" to quit and it promps me back in the game were now when ever i do "4" or "q" is will keep bringing be back to each other🥲

royal lintel
azure swift
#

no worries !! only if you have time 🙂 and that kina worked it ends the game completely but its supost to go back to the main menu

#

im gana take a break from this for now. i been doing it to long haha thx you for your help tho 🙂

royal lintel
#

@azure swift did you fix it?

azure swift