Skip to main content
Code Review

Return to Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

The answer to this question this question suggests the following:

''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(length))

It's close to your solution, but avoids having to type out the whole alphabet by using predefined values and avoids the use of map() and lambda.

The answer to this question suggests the following:

''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(length))

It's close to your solution, but avoids having to type out the whole alphabet by using predefined values and avoids the use of map() and lambda.

The answer to this question suggests the following:

''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(length))

It's close to your solution, but avoids having to type out the whole alphabet by using predefined values and avoids the use of map() and lambda.

Recommend ascii_lowercase directly
Source Link
200_success
  • 145.5k
  • 22
  • 190
  • 478

The answer to this question suggests the following:

''.join(random.choice(string.ascii_uppercaseascii_lowercase + string.digits) for _ in range(Nlength))

It's close to your solution, but avoids having to type out the whole alphabet by using predefined values and avoids the use of map() and lambda. For your purpose, I think you'd want string.ascii_lowercase instead of string.ascii_uppercase.

The answer to this question suggests the following:

''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(N))

It's close to your solution, but avoids having to type out the whole alphabet by using predefined values and avoids the use of map() and lambda. For your purpose, I think you'd want string.ascii_lowercase instead of string.ascii_uppercase.

The answer to this question suggests the following:

''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(length))

It's close to your solution, but avoids having to type out the whole alphabet by using predefined values and avoids the use of map() and lambda.

Source Link
Tom Barron
  • 856
  • 7
  • 15

The answer to this question suggests the following:

''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(N))

It's close to your solution, but avoids having to type out the whole alphabet by using predefined values and avoids the use of map() and lambda. For your purpose, I think you'd want string.ascii_lowercase instead of string.ascii_uppercase.

lang-py

AltStyle によって変換されたページ (->オリジナル) /