我在运行代码时收到此错误,并且不知道为什么如果一切都正确缩进,我的运行总计将无法工作。这是我得到的错误:
totalRooms += rooms
^
TabError: inconsistent use of tabs and spaces in indentation
这是我的程序:
def main():
developerInfo()
totalFloors = int(input('Enter the number of floors in the hotel: '))
totalRoomsOccupied = 0
totalRoomsUnoccupied = 0
totalRooms = 0
for hotelRateLoop in range(totalFloors):
rooms = int(input('Enter the number of rooms on the floor: '))
roomsOccupied = int(input('Enter the number of rooms occupied: '))
roomsUnoccupied = int(rooms - roomsOccupied)
totalRooms += rooms
totalRoomsOccupied += roomsOccupied
totalRoomsUnoccupied += roomsUnoccupied
occupancyRate = float(totalRoomsOccupied / totalRooms)
print('Total number of rooms: ' + str(totalRooms))
print('Total number of rooms occupied: ' + str(totalRoomsOccupied))
print('Total number of rooms unoccupied: ' + str(totalRoomsUnoccupied))
print('Occupancy Rate: ' + format((occupancyRate * 100), '.2f') + '%')