Getting TypeError

I’m getting the error. Please help.

This post isn’t pertinent to this forum. Essentially you are using Python or IPython in Jupyter for this. You’d have the same issues whether you ran this in Jupyter or a Python/IPython console/interpreter or a traditional Python or IPython script. You would ideally seek help in locations meant to support those topics and not here. That consideration of whether running the code in Jupyter would be different than running in Python/IPython in more traditional ways is always helpful for you when trying to understand where your issue actually lies.
Keep in mind that Jupyter runs a lot of different languages and so you should always focus on the language you are using. (You cut off the kernel indicator on the right side of your image.) Also, wherever you post for help, this post wouldn’t be acceptable. If you are using code and have code and errors, always post the code and errors as text and not images. No one trying to help you wants to retype code you had and could have provided.
All that being said, a lot of people also are very familiar with Python here, …

In this case, I would guess you ruined Python’s set type earlier in your coding endeavor. It may have been as simple as a syntax error that you made that clobbered set or associated methods. You should always also re-run the minimal code block you are going to share in a new session or restart the kernel and only run that. Had you done that, you would have seen the lines setting A and B in that code you shared would run just fine in that fresh situation. And then you could have further worked on troubleshooting this yourself. You probably clobbered or accidentally shadowed the built-in set earlier in your notebook in the other 22 cells you ran previously. You may no longer even have the cell or code where you re-assigned set to something else. Often that is called the ‘hidden state’ that you can easily get in a interpreter or Jupyter session. The easiest way to avoid that is to restart the session or kernel regularly and re-run the code you have left. That way you can catch where you broke things much faster.