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"
clusters[i]actually contains a number (or whatever type you intended) by reading the output ofprint type(clusters[i]).for i in range(len(foo)):you're probably doing it wrong. Do insteadfor i, sublist in kclust.enumerate():and the list comp can be[userobjectIds[v] for v in sublist[:3]]enumerate(kclust)(unlessklustis something different than a list). But this is definitely the correct approach.