random.shuffle()
を使用せずに文字列 "string"をスクランブルしようとしていますが、コードでは、 gtrgtg、gnrtnnなど私は間違って何をやっているのか分からない。random.shuffle()を使用せずにPythonで文字列をスクランブルする
import random
s = "string"
new_s=[]
for c in s:
if random.choice(s) not in new_s:
new_s.append(random.choice(s))
print(''.join(new_s))
あなたは正しいと思います。 –