Reputation: 182
I am making a program to make 12 word long phrases using the bip39
wordlist.
However with the code I wrote I am getting an error I do not know how to fix.
Code:
import requests
import random
r = requests.get("https://raw.githubusercontent.com/bitcoin/bips/master/bip-0039/english.txt")
def make_seed():
return "".join([random.choice(r.text.split("\n")) + " "] for i in range(12))
print(make_seed())
Output: TypeError: sequence item 0: expected str instance, list found
Expected output: 12 letter phrase from the wordlist.
I tried turing the random.choice(r.text.split("\n"))
into a str but that doesn't seem to work.
Upvotes: 2
Views: 76
Reputation: 6760
The join
method requires as its argument an iterable of str
objects. Your iterable is of list
objects. Try removing the brackets from that line. I.e.,
return "".join(random.choice(r.text.split("\n"))+" " for i in range(12))
Upvotes: 2