-1

Those were the code snippets from CS50 2022 - Lecture 9 - Flask.

<select name="sport">
    <option disabled selected>Sport</option>
    {% for sport in sports %}
        <option value="{{ sport }}">{{ sport }}</option>
    {% endfor %}
</select>

Are the double quotes around the string 'sport' unnecessary as 'sport' is already a string with double quotes? I personally want to write something like this, a little bit differently, without the quotes around {{ sport }}

<select name="sport">
    <option disabled selected>Sport</option>
    {% for sport in sports %}
        <option value={{ sport }}>{{ sport }}</option>
    {% endfor %}
</select>
Đạt Phạm
  • 13
  • 1
  • 7

1 Answers1

-1

Yes, the quotes are unnecessary, you can write this code like this:

<select name="sport">
    <option disabled selected>Sport</option>
    {% for sport in sports %}
        <option value={{ sport }}>{{ sport }}</option>
    {% endfor %}
</select>
Nathan
  • 7
  • 3
  • Please provide support for your answer (documentation, another stackoverflow answer, personal experimentation with input/outputs, etc) – Fractalism Jan 31 '23 at 17:09