Mar-20-2022, 08:19 AM
Expecting
Someone will type text, so line 1 should be expanded to something like:
n = int(input())
to always return a number would be naive.Someone will type text, so line 1 should be expanded to something like:
def get_num(): n = None while(not isinstance(n, int)): n = input("Please enter a number: ") try: n = int(n) except ValueError: print(f"{n} is not numeric, try again") return n n = get_num()also, there is a builtin for line 2 in string:
# at top of script: import string # ... alpha = string.ascii_lowercase