I am trying to print the elements of a list inside a loop but the elements are displaying surrounded by ['']. Is there any way to format output to remove these. Further code and examples shown below
This is the code i am running:
for i in range(len(get_recipe_titles)):
if i ==0:
j = get_recipe_titles[i];
Title = recipedf[recipedf['id'] == j]
Title = Title['title'].values
print('Recipe Recommendations for: {0}'.format(Title[0]))
else:
j = get_recipe_titles[i];
Title = recipedf[recipedf['id'] == j]
Title = Title['title'].values
Distance =dist.flatten()[i]
i = i+1
print(Title, "With Distance of ", Distance)`
The output is this. I want the [''] removed from the titles of the recepies:
Recipe Recommendations for: Three-tier red velvet cake
['Daffodil biscuits'] With Distance of 2.23606797749979
['Belgian waffles'] With Distance of 2.449489742783178
['Easy brownies'] With Distance of 2.6457513110645907
['Red velvet cake'] With Distance of 2.6457513110645907
["Cheat's waffles"] With Distance of 2.6457513110645907
['Scary Halloween cookies'] With Distance of 2.6457513110645907
['Chocolate chip muffins'] With Distance of 2.8284271247461903
['Bundt cake'] With Distance of 2.8284271247461903
['Chocolate beetroot cakes'] With Distance of 2.8284271247461903
I have used .format() in the code above to print the title on the first line of the output without Brackets and Quotes but cant seem to use it for the rest of the output. Is there any way to remove them or is there anywhere i am going wrong