You are correct that the for loop in the official solution is incorrect, as it will not iterate to the last floor due to the "left inclusive interval" nature of range(). 0 <= x <= 1 = ....(start, end] The correct solution should be to use the range function with the argument range(1, floors+1) instead of range(1, floors) in order to include the last floor in the iteration. This will ensure that all floors that are multiples of 5 are included in the output.
Kukusik Péter , the issue is not the for loop. > when using a range like: *range(3, 10)* the start number (3 ) is included in the range. the stop number (10) is excluded, so this range generates: 3, 4, 5, 6, 7, 8, 9 > for our case to get the stop number included we have to use: range(3, 10 +1)
Kukusik Péter Share the link of the problem
The challenge: Nearest Restaurant A group of buildings has a restaurant on every 5th floor. In other words, a building with 12 floors has restaurants on the 5th and 10th floors. Task Create a program that takes the total number of floors as input and outputs the floors that have restrooms. Sample Input 17 Sample Output 5 10 15 Official solution: floors = int(input()) for i in range(1, floors): if i%5 == 0: print(i) I think this for loop wrong because never go to the last floor. The correct is for i in range(1, floors+1):