Help Stir letters in words text
In this code nothing happens
from nltk.tokenize import word_tokenize
Import Random
A = "SOME TEXT"
A1 = Word_Tokenize (a)
For i in a1:
Random.Shuffle (i.split ())
Print ('' .join (A1))
Answer 1, Authority 100%
import random
Text = "Some Text"
Words = Text.Split ()
For i, Word in Enumerate (Map (List, Words)):
Random.Shuffle (Word)
Words [i] = '' .join (Word)
Print (* Words) # - & gt; Eosm TXet.
lines are immutable in python, so to mix the letters in the words of the text, each word is converted to the character list, the list is mixed, then the combined characters back to the word list are assigned.
In the general case, the words on the letters can not only be embarrassed (on separate Unicode Code Points) break. See How to split the string to separate characters?
Answer 2, Authority 17%
I can offer this option:
import random
Slovo = 'Hi'
Slovo_List = List (Slovo)
Abrakadabra = Random.Sample (Slovo_List, Len (Slovo_List))
Print (Abrakadabra)