3 ms·
I'd say that the correct answer would be "Which version of Python are you using?" but I actually kind of like the question - it's an important enough function t
by fencepost 10y ago
I'd say that the correct answer would be "Which version of Python are you using?" but I actually kind of like the question - it's an important enough function that most people doing more than toy projects would have needed to use it at some point or at least would have considered it, but it's also something that has changed recently enough that people who are claiming long-term experience will have dealt with both versions.
My Python is rusty, but I actually had to go look up the differences - my initial thought was "I'm pretty sure it used to be that range() generated a list and xrange() basically just iterated a value, but at some point range() was changed to use the xrange() behavior - I'd have to look it up to give you more detail than that." I didn't realize that xrange() had been completely removed from 3.x, for example. For that matter, I was thinking that both of them might have existed in 1.x, though it looks like they were added in 2.0.