FAQ: Learn Python - Battleship - To Your Battle Stations!

faq

#1

This community-built FAQ covers the “To Your Battle Stations!” exercise in Codecademy’s lessons on Python.

FAQs for the Codecademy Python exercise To Your Battle Stations!:

Join the Discussion. We Want to Hear From You!

Have a new question or can answer someone else’s? Reply (reply) to an existing thread!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources about Python in general? Go here!

Want to take the conversation in a totally different direction? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account, billing, Pro, or Pro Intensive? Reach out to our support team!

None of the above? Find out where to ask other questions here!


#2

2 posts were split to a new topic: range() and index() Count Differently


#3

How to handle invalid input?
I accidentally hit Return without entering a number, which gave me the idea to check if player input for Battleship was a valid number.
But it seems I can’t check if the input was a number:
raw_input will always be a string first.
But as soon as I call int() on something that is not a number-string, I get an “invalid literal for int()” error.
I want to ask “Is the input an integer?” without running into that error.

I would be interested to learn how I can do this check!
Thanks a lot.


#4

How could I modify my code to stop printing the board again in case of “Game Over”, just like it doesn’t print it again in case of a win?