0

To find primes, why do i need to specify a range from 1 to the input number +1. Why +1

num = int(input("")) ListRange = list(range(1, num+1)) Why num+1, why is (1,num) not enough?

19th Apr 2019, 5:38 PM
Desi
2 Answers
+ 1
With range(start, stop) the last number is not included, so if you want to include it you need to add one to it. For example, range(2, 6) will include only 2, 3, 4, and 5.
19th Apr 2019, 5:46 PM
Heather
Heather - avatar
0
thank you very much
19th Apr 2019, 11:19 PM
Desi