dimanche 18 septembre 2022

how to get a A SUGGESTION, not just a word in python

i have a list of suggestion parsed from json which look likes ['just a suggestion', 'and this too suggestion', 'dont care, this suggestion']

and i write this code:

import json
import random
import dpath.util as dp

with open('.logs') as json_file:
    data = json.load(json_file)
    res = dp.values(data, "/posts/*/com")
    file = open(".text", "w")
    file.write(str(res))
    file.close()
    file = open(".text", "r")
    tt = file.read()
    text = random.choice(tt.split())
    print(text)

but, this give to me only words. something like care or another word from list. how do i get a random suggestion from a list?




Aucun commentaire:

Enregistrer un commentaire