Last answered:

13 Jan 2022

Posted on:

12 Jan 2022

0

Defined class without the pass keyword

Created a class without the pass keyword at the end of the class and it worked perfectly.
Want to know why it worked without the pass keyword.
Below is the code and output.
imageimage

1 answers ( 0 marked as helpful)
Instructor
Posted on:

13 Jan 2022

2

Hey Sylvester,

Thank you for your question!

Note that inside this class you have a docstring, namely:

''' Store patient information '''

This is not perceived as a usual comment, therefore your class is not 'empty'. Try substituting the above with

# Store patient information

or try removing it altogether. What you should get then is a parsing error. Therefore, in the absence of this docstring or any other piece of code, you should write pass to create a placeholder for this class and avoid such errors.

Hope this helps!

Kind regards,
365 Hristina

Submit an answer