zhiwehu / Python-programming-exercises

100+ Python challenging programming exercises
26.72k stars 6.82k forks source link

Wrong solution on line 1953 #82

Open Joshua-Burt opened 5 years ago

Joshua-Burt commented 5 years ago

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))

tictaktoe333 commented 4 years ago

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

amitShindeGit commented 4 years ago

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