Python-programming-exercises icon indicating copy to clipboard operation
Python-programming-exercises copied to clipboard

Wrong solution on line 1953

Open Joshua-Burt opened this issue 6 years ago • 2 comments

https://github.com/zhiwehu/Python-programming-exercises/blob/22bb9b343f009a1d710117b02f5b278e0761094f/100%2B%20Python%20challenging%20programming%20exercises.txt#L1942

https://github.com/zhiwehu/Python-programming-exercises/blob/22bb9b343f009a1d710117b02f5b278e0761094f/100%2B%20Python%20challenging%20programming%20exercises.txt#L1953

The solution shown is print(random.sample(range(100), 5))

However that will only generate numbers between 0 and 100, but the question asks for 100 to 200.

The solution should be print(random.sample(range(100, 200), 5))

Joshua-Burt avatar Aug 05 '19 23:08 Joshua-Burt

The solution should be print(random.sample(range(100, 201), 5))

Since 200 should be included in the output, your solution forgot that range stop is n-1

tictaktoe333 avatar Jan 18 '20 21:01 tictaktoe333

Thank you,Joshua-Burt and ticktaktoe33 for pointing this out,made a PR regarding the issue.

amitShindeGit avatar Oct 02 '20 05:10 amitShindeGit