Tushar Goel wrote:How are you trying to print them? Can you please show us?
Mike. J. Thompson wrote:You print statement does not appear in your for-loop. This means that there will only ever be at-most one print statement executed. If you want to print out every digit then you need to move the print statement into the for-loop.
Are you sure it only prints digits that appear first though? It looks to me like the local variable 'c' will only ever contain the final character from the String.
Junilu Lacar wrote:Pile of rocks ==> your array of letters
Bucket ==> a list that can hold any number of things
Pick a number, any number ==> generate a random number
Throw X rocks from the pile into that bucket => add (random number of whatever) from ? to ?
In your code:
You say that this always prints out the same length -- why do you think it does that? What is that length that's always the same right now? In your code, what controls how many times this loop executes? If you want to execute the loop X number of times, what do you change? If you want to execute X number of times where X is some arbitrary number what do you need to do?
Junilu Lacar wrote:So if I say "Pick a number, any number" and you pick a number. Then I say, "See that pile of rocks over there? Go over to that pile of rocks and throw as many rocks as that number you just picked in that bucket over there."
That's kind of what you have to do. Do you know how to add things to a List?
Junilu Lacar wrote:Do you know how to generate a random number? That's where you want to start. Once you can generate a random number, the next step is to create a list with an arbitrary length by adding elements X number of times, where X is an arbitrary number.