T = ['.', ',', '-', 'hola', 'soy', 'Alexander']
simbolos = ['.', ',', '-']
texto = []
while len(texto) < 73:
if len(texto) == 0:
pal1 = random.choice(T)
if pal1 not in simbolos:
texto.append(pal1)
else:
sgt_pal = random.choice(T)
if texto[-1] in simbolos and sgt_pal not in simbolos:
if texto[-1] == ',':
texto.append(' ' + sgt_pal)
elif texto[-1] == '.':
texto.append('\n' + sgt_pal)
else:
texto.append(sgt_pal)
elif texto[-1] not in simbolos and sgt_pal not in simbolos:
texto.append(' ' + sgt_pal)
elif texto[-1] not in simbolos and sgt_pal in simbolos:
texto.append(sgt_pal)
else:
pass
with open('literatura.txt', 'w') as f:
f.writelines(texto)
Este es el código del programa,necesito asegurarme de que hayan 73 términos, incluyendo los simbolos y excluyendo los espacios, pero no se como hacer para separar todo sin decir específicamente en que palabras y simbolos quiero que se separe.