"I cannot properly implement input validation"
"Attempted Try and Except but to no avail"
#Variables
floors = [];
n = int(input('Enter number of floors of the hotel : '));
totalRooms = 0;
occupiedRooms = 0;
#Input Process
while True:
for i in range(0, n):
print ('For floor ' + str(i + 1) + ' : ');
try:
rooms = int(input('Enter the number of rooms : '));
occupied = int(input('Enter the number of rooms occupied : '));
floors.append([rooms, occupied]);
except ValueError:
print("Try again")
totalRooms = totalRooms + rooms;
occupiedRooms = occupiedRooms + occupied;
#Display Information
print ('Total Rooms : ' + str(totalRooms));
print ('Total Rooms Occupied: ' + str(occupiedRooms));
print ('Total Rooms Unoccupied: ' + str(totalRooms - occupiedRooms));
print ('Percent of Rooms Occupied: ' + str(((occupiedRooms * 1.0) / (totalRooms * 1.0)) * 100));
I would like to have it so it keeps asking the user until they input a number