I try to execute following code but can't with mistake: name 'xrange' is not defined
pages = (
requests.get(
build_group_request({
"offset": WINDOW_SIZE * i,
"count": WINDOW_SIZE,
"fields": "sex,interests,bdate"
})
).json()['response']['items']
for i in xrange(int(float(COUNT) / 100 + 1))
)
The “NameError: name 'xrange' is not defined” error is raised when you try to use the xrange() method to create a range of numbers in Python 3. To solve this error, update your code to use the range() method that comes with Python 3. range() is the Python 3 replacement for xrange() .
The NameError: name 'raw_input' is not defined occurs when you try to call the raw_input() function using Python major version 3. You can only use raw_input() in Python 2. To solve this error, replace all instances of raw_input() with the input() function in your program.
You're probably using Python3, where xrange
has become range
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With