Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 18 Online
OpenStudy (anonymous):

I'm new here, and I need to know how to generate a list of numbers from 1 to 9999 for example, when using "for x in range(1,9999)" its not working at all

OpenStudy (anonymous):

I have tried: for x in range(1,9999): print x and it's working. Do you get some kind of error message?

OpenStudy (anonymous):

the range function will generate a Python list. how are you trying to use it? http://docs.python.org/tutorial/controlflow.html#the-range-function http://docs.python.org/library/functions.html#range

OpenStudy (carlsmith):

I'm not sure dr_road12, `for x in range(1, 9999)` should work fine, in fact, `for x in range(n)` is a very common way to knock up an iterator in Python. Are you sure you're not forgetting the colon? Every header ends in a colon... for x in range(1, 9999): print x

OpenStudy (anonymous):

I agree with carlsmith, you probably forgot the colon. I've done it a hundred times and it's frustrating scouring your code to find you forgot a simple colon.

OpenStudy (anonymous):

if using python use the .randit function. same function you would use for a numbers guessing game

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!