Not sure what I'm doing wrong here. Fails extras.
def house(plan): # excepts no building if '#' not in plan: return 0 # excepts 1 building if (plan.count('#')) == 1: return 1 # splits string into list of strings new = plan.splitlines() # removes buildingless rows while '#' not in new[0]: new.pop(0) while '#' not in new[-1]: new.pop() # rotates array new2 = '' for i in range(len(new[0])): for x in range(len(new)): new2 += new[x-1][i-1] new2 += '\n' # splits string into list of strings new2 = new2.splitlines() # removes buildingless rows while '#' not in new2[0]: new2.pop(0) while '#' not in new2[-1]: new2.pop() #return area area = len(new2) * len(new2[0]) return area if __name__ == '__main__': print("Example:") print(house(''' 0000000 ##00##0 ######0 ##00##0 #0000#0 ''')) #These "asserts" using only for self-checking and not necessary for auto-testing assert house(''' 0000000 ##00##0 ######0 ##00##0 #0000#0 ''') == 24 assert house('''0000000000 #000##000# ########## ##000000## 0000000000 ''') == 30 assert house('''0000 0000 #000 ''') == 1 assert house('''0000 0000 ''') == 0 assert house(''' 0##0 0000 #00# ''') == 12 print("Coding complete? Click 'Check' to earn cool rewards!")