Reputation: 1
I am getting this:
0.0 angry27.56%
0.0 disgust0.0%
0.0 fear18.75%
0.0 happy14.47%
0.0 sad5.34%
0.0 surprise14.96%
0.0 neutral18.92%
I want to get this:
0.0 angry27.56%, disgust0.0%, fear18.75%, happy14.47%, sad5.34%, surprise14.96%, neutral18.92%
I am using this code:
emotion = ""
for i in range(len(predictions[0])):
emotion = "%s%s%s" % (emotions[i], round(predictions[0][i]*100, 2), '%')
print(str(sec)+ " " + emotion)
Upvotes: 0
Views: 623
Reputation: 11
First create a empty list then append all values of emotion in it then use join() to combine elements of list :
emotion = ""
res = []
for i in range(len(predictions[0])):
emotion = "%s%s%s" % (emotions[i], round(predictions[0][i] * 100, 2), '%')
res.append(emotion)
print(str(sec), end=" ")
print(", ".join(res))
Upvotes: 1
Reputation: 97
print(str(sec)+ " " + emotion,end=', ')
end=' '
parameter inside the print statement can be used to print output in a single line....
Upvotes: 1