[Tutor] simple random string generator
steve at pearwood.info
Mon Sep 17 06:33:41 CEST 2012
On 17/09/12 12:45, Matthew Dalrymple wrote:
> Anyway what i am trying to do is make a simple string (word)
> generator and get it to make strings (or words) starting at 10 chars
> up to 100 in steps of 5 using a make word function. Now my problem
> is how do i get it to run the mkword function and manipulate the n
> value to fit those requirements?
Use a for-loop.
for n in range(10, 101, 5):
The print is just as a demonstration. In your code, you would instead
call your mkword function.
>i am just having problems learning python...like in understand it, i
> can read it, and know what is going on and what needs to be done...but
>when it comes to writing it i just dont know how to do it...
Hang in there mate, practice makes perfect. Writing code is a combination
of creativity and careful, precise, logical reasoning. Some people find
it easy, some people don't.
When you have a task, try breaking it up into simple steps, like you were
giving instructions to your two-year-old cousin. (In reality, computers
are *much* dumber than a two-year old, but that's a good start.)
> does anyone else have this prob?
I'm sure most people have had this problem for at least a little while.
> and is there anything i can do to start really soaking it in?
Write code. Lots of code. It doesn't matter if it is junk code, or toy
code, just write lots of code, until it becomes second nature.
More information about the Tutor