you can use enumerate()
and use str.rstrip()
to remove the all types of trailing whitespaces from the string. and you can also use rstrip('\n')
if you're sure that the newline is going to be \n
only.:
for i,x in enumerate(t,1):
print ("{0}. {1}".format(i,x.rstrip()))