Python Attributeerror Nonetype Object Has No Attribute Groups