Update main.py

replace big for loop with a function that does the same thing
Update main.py
Update main.py
Merge pull request #2 from MaxraySavage/cleaner-code

Cleaner code (fix #1)