[Tutor] Battleships - Error with blank input

dn PythonList at DancesWithMice.info
Wed May 3 20:13:16 EDT 2023


On 04/05/2023 10.09, Sharj Ahmed wrote:
> Hi all,
> 
> Need some help with my code.
> 
> I've written the below code, but need to add some validation in for when
> the user inputs nothing.
> 
> The blank input for rows and columns causes the application to crash.

Try:

     "" in "123"

Does that help?

There is a feature of Python known as 'truthiness', so

     if row:
         # check if valid row
     else:
         # problem


> Any help would be greatly appreciated!
> 
> Here is my code:

Sadly, the email formatting was difficult to read, and because newlines 
and indentation were affected, there may be errors we can't detect...


> The error message that appears is:
> [image: image.png]

Attachments do not come through.

Please copy-paste the text.

-- 
Regards,
=dn


More information about the Tutor mailing list