Defineed function and an array was added to condense python program making it easier to read