0
I am creating a program that shuffles all the letters of the words inside a file . txt in which each line there is only one word.
Example of a . txt (which I called Wordlist.txt):
batata
limonada
áfrica
How I expect output to be:
atabat
adaoilmn
ficára
What I tried to do:
import random
with open('wordlist.txt', encoding='utf-8') as f:
lines = f.readline()
list = list(lines)
random.shuffle(list)
result = ''.join(list)
print(result)
Output:
limonada
batata
áfrica
In my attempt, the program only scrambles the order in which words are presented.
My goal is that the order in which the words are presented stays the same, but with each word having its letters shuffled.