Skip to content
Advertisement

Python :TypeError: this constructor takes no arguments

When the user enters an email address, and the program reads the email and display it according to its criteria (e.g yeo.myy@edu.co), like criteria:

  • username is yeo.myy
  • domain is edu.co

I know its something to do with the "@".

this is the code

JavaScript

this is the error I got:

JavaScript

Advertisement

Answer

JavaScript

Did you mean __init__?

JavaScript

You’re also missing a couple selfs in your methods, and your returns are improperly indented.

JavaScript

Result:

JavaScript

Incidentally, I recommend partition and rpartition for splitting a string into two pieces on a given separator. Sure beats keeping track of indices manually.

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement