assertion error python how to return Error code example
Example: make an assertionerror in python
# ask for a name
answer = input("Please enter your name:")
# make sure it consists of only alphabetical characters (a-z/A-Z)
# assert <condition: bool>, <Error message: str>
assert all([1 if char.isalpha() else 0 for char in answer]) == True, "Please make sure your name consist of only alphabetical characters."