Python equivalent for hacking PHP?

Is there an equivalent for a PHP attack in Python? I read and shared a set of separated words, and now I want to sort them in random order and print the words with gaps between them.

implode - combine array elements with string

http://php.net/manual/en/function.implode.php

+56
python php implode
Aug 21 2018-12-12T00:
source share
2 answers

Use the join-method strings.

print ' '.join(['word1', 'word2', 'word3']) 

You can join any iterable (not just the list used here), and of course you can use any string (not just ' ' ) as a delimiter.

If you need random order, as you said in your question, use shuffle .

+116
Aug 21 2018-12-12T00:
source share

Ok, I just found a function that does what I wanted to do,

I read in a file with words in the format: Jack / Jill / mine / kill / name / Bucket

Then I split it using the .split method, and as soon as I got the word into an array, I linked the words using this method:

 concatenatedString = ' - '.join(myWordList) # ie: delimeter.join(list) 

Thanks for your answers if you already have one!

+11
Aug 21 2018-12-12T00:
source share



All Articles