Nov-20-2019, 09:38 PM
(This post was last modified: Nov-20-2019, 09:39 PM by newbieAuggie2019.)
(Nov-20-2019, 09:17 PM)Drone4four Wrote: From this code snippet, as you can see, if there is a single integer passed into the range() function, it starts at 0 and goes up to but does not include the final number in the generated list. In this way it's similar to list slicing. But when passing in parameters into randint(), the result includes any integer from the beginning parameter as well as up to (and including) the final integer at the end. This isn't quite as easy to remember.
Hi!
You could use mnemonics:
If you are a RANGER (for range()), you are a good guy, and don't reach the last limit ...
If you are RANDY (for randint()), you reach the limits ...
All the best,
newbieAuggie2019
"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs
"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs