I'm new to programming so bear with me please!
I'm creating a class and having trouble getting the return message to show when the users input is empty.
Instead of returning my message it's just throwing me an error.
I want my code to return "please try again" and end, if the user input is blank.
Code:
class BankAccount():
def __init__(self):
# asking for a name
self.name = str(input("Hello! Welcome to the Bank of Alex.\nWhat is your name?"))
if self.name == "":
return "please try again"
else:
print(f"\nWelcome, {self.name.title()}.")
TypeError Traceback (most recent call last) in ----> 1 account = BankAccount()
TypeError: init() should return None, not 'str