Skip to main content
Edited question title and removed language tag. Improved grammar.
Source Link
martineau
  • 124.1k
  • 29
  • 181
  • 319

Explain Python What exactly does the .join() method do?

I'm pretty new to Python and am completely confused by .join() which I have read is the preferred method for concatenating strings.

I trytried:

strid = repr(595) print array.array('c', random.sample(string.ascii_letters, 20 - len(strid))) .tostring().join(strid) 

and getgot something like:

5wlfgALGbXOahekxSs9wlfgALGbXOahekxSs5 

Why does it work like this? Shouldn't the 595 just be automatically appended?

Explain Python .join()

I'm pretty new to Python and am completely confused by .join() which I have read is the preferred method for concatenating strings.

I try:

strid = repr(595) print array.array('c', random.sample(string.ascii_letters, 20 - len(strid))) .tostring().join(strid) 

and get something like:

5wlfgALGbXOahekxSs9wlfgALGbXOahekxSs5 

Why does it work like this? Shouldn't the 595 just be automatically appended?

What exactly does the .join() method do?

I'm pretty new to Python and am completely confused by .join() which I have read is the preferred method for concatenating strings.

I tried:

strid = repr(595) print array.array('c', random.sample(string.ascii_letters, 20 - len(strid))) .tostring().join(strid) 

and got something like:

5wlfgALGbXOahekxSs9wlfgALGbXOahekxSs5 

Why does it work like this? Shouldn't the 595 just be automatically appended?

deleted 4 characters in body
Source Link
Rahn
  • 5.6k
  • 5
  • 38
  • 74

I'm pretty new to Python and am completely confused by .join().join() which I have read is the preferred method for concatenating strings.

I try:

strid = repr(595) print array.array('c', random.sample(string.ascii_letters, 20 - len(strid))) .tostring().join(strid) 

and get something like:

5wlfgALGbXOahekxSs9wlfgALGbXOahekxSs5 

Why does it work like this? Shouldn't the '595'595 just be automatically appended?

I'm pretty new to Python and am completely confused by .join() which I have read is the preferred method for concatenating strings.

I try:

strid = repr(595) print array.array('c', random.sample(string.ascii_letters, 20 - len(strid))) .tostring().join(strid) 

and get something like:

5wlfgALGbXOahekxSs9wlfgALGbXOahekxSs5 

Why does it work like this? Shouldn't the '595' just be automatically appended?

I'm pretty new to Python and am completely confused by .join() which I have read is the preferred method for concatenating strings.

I try:

strid = repr(595) print array.array('c', random.sample(string.ascii_letters, 20 - len(strid))) .tostring().join(strid) 

and get something like:

5wlfgALGbXOahekxSs9wlfgALGbXOahekxSs5 

Why does it work like this? Shouldn't the 595 just be automatically appended?

added 2 characters in body; edited tags
Source Link
SilentGhost
  • 322.1k
  • 67
  • 312
  • 294

I'm pretty new to Python and am completely confused by .join() which I have read is the preferred method for concatenating strings.

I try:

strid = repr(595) print array.array('c', random.sample(string.ascii_letters, 20 - len(strid))) .tostring().join(strid) 

and get something like:

5wlfgALGbXOahekxSs9wlfgALGbXOahekxSs5

5wlfgALGbXOahekxSs9wlfgALGbXOahekxSs5 

Why does it work like this? Shouldn't the '595' just be automatically appended?

I'm pretty new to Python and am completely confused by .join() which I have read is the preferred method for concatenating strings.

I try:

strid = repr(595) print array.array('c', random.sample(string.ascii_letters, 20 - len(strid))) .tostring().join(strid) 

and get something like:

5wlfgALGbXOahekxSs9wlfgALGbXOahekxSs5

Why does it work like this? Shouldn't the '595' just be automatically appended?

I'm pretty new to Python and am completely confused by .join() which I have read is the preferred method for concatenating strings.

I try:

strid = repr(595) print array.array('c', random.sample(string.ascii_letters, 20 - len(strid))) .tostring().join(strid) 

and get something like:

5wlfgALGbXOahekxSs9wlfgALGbXOahekxSs5 

Why does it work like this? Shouldn't the '595' just be automatically appended?

Source Link
Matt McCormick
  • 13.2k
  • 23
  • 78
  • 84
Loading