TypeError: can't assign a str to a torch.LongTensor

Hello i’m trying assign list of strings into tensor but it gives me this error

this is the code
# Merge captions (from tuple of 1D tensor to 2D tensor).
lengths = [len(cap) for cap in captions]
    targets = torch.zeros(len(captions), max(lengths)).long()
    for i, cap in enumerate(captions):
        end = lengths[i]
        targets[i, :end] = cap[:end]

for people who might want the answer I converted the string to it’s unicode and stored it in the tensor
here’s the answer

targets[i, :end] = torch.from_numpy(np.array(list(map(ord, cap[:end])))).to(torch.long)