jchen8000 commited on
Commit
8b72576
·
verified ·
1 Parent(s): dd45133

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -56,9 +56,11 @@ def recommend_movies(movie):
56
  max_length = movies['title'].str.len().max()
57
  print(f"The longest movie name length is: {max_length}")
58
 
59
- headers = "Title{:20}Score".format("")
60
- return headers + "\n" + "\n".join([f"{title:<20} {score:>5.2f}" for title, score in recommendations])
61
 
 
 
62
 
63
 
64
  # Create the Gradio interface
 
56
  max_length = movies['title'].str.len().max()
57
  print(f"The longest movie name length is: {max_length}")
58
 
59
+ # headers = "Title{:20}Score".format("")
60
+ # return headers + "\n" + "\n".join([f"{title:<20} {score:>5.2f}" for title, score in recommendations])
61
 
62
+ format_string = f"{{:<{max_length}}}: {{:>5.2f}}"
63
+ return "Title" + " " * (max_length - 5) + "Score\n" + "\n".join([format_string.format(title, score) for title, score in recommendations])
64
 
65
 
66
  # Create the Gradio interface