4 ответов
+ 8
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)
+ 2
Kukusik Péter Share the link of the problem
+ 1
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):