Reputation: 753
i'm not sure if this is the correct syntax to do this, but i want to print out a specific element in a list.
user,activity,data=readfile('data.txt')
kclust,clusters=kcluster(data,k=3)
for i in range(len(kclust)):
print "Cluster %d: ??" % (i+1,clusters[i])
print [[userobjectIds[r] for r in kclust[i]][:3]]
print
the '??' is where i've tried %d and %o but get: "TypeError:%o format:a number is required, not list"
Upvotes: 0
Views: 1190
Reputation: 23110
I don't know about kcluster function, but it seems it returns a list, not a number. Alternatively, you could try:
print "Cluster %d:"%(i+1), clusters[i]
Upvotes: 0
Reputation: 816262
'r': String (converts any Python object using
repr()
).
print "Cluster %d: %r" % (i+1,clusters[i])
Upvotes: 5