Nov-12-2018, 03:23 AM
I've heard the whole "design functions to do one thing well" mantra, but it's still a little vague to me. Recently I've been working on an input processing script which is based off of instructions from a book. Right now I'm worried if I've split up the functions too much. This is what I have so far:
def check_input(digit_input): if digit_input.isdigit() is not True: print("Error: input contains non-numbers. Exiting.") else: if len(digit_input) == 6: return digit_input else: print("Error: number of digits is not six. Exiting") def input_to_list(digit_input): digit_list = list(digit_input) return digit_list def chksum_extraction(digit_list): check_sum = digit_list.pop(-1) return check_sum return digit_list digit_input = input("Enter six digit ID: ") check_input(digit_input)I think knowing whether or not this is organized well will give me a concrete example when working on future programs.