'HTML Input value not displaying after first comma when reading python string

So, i have a Flask App where the user can adjust some values via an input. The default value of the input will not display correctly if it is reading a python string that is in the form of a list.

so in my main.py i define the following variable:

python_string_list = "1,2,3,4"

in my page.html i have:

<input type="text" name="MJ" id="MJ" value={{python_string_list}}>

but the default value that appears in the input box on the html page is just: 1,

if, however i use:

<input type="text" name="MJ" id="MJ" value="1,2,3,4">

the whole list appears, as expected.

Not sure what im doing wrong but would really appreciate some help.

Edit: Seems the error cant be replicated so i will add the full code. Not sure if it makes a difference but my input box is in a table:

<div class="table-responsive">
    <table class="table align-items-center table-flush">
        <thead class="thead-light">
            <tr>
                <th class="border-bottom" scope="col"> Title </th>
            </tr>
        </thead>
        <tbody>
            <tr class "fw-bolder text-gray-500">
                <input type="text" name="MJ" id="MJ" value={{python_string_list}}>
            </tr>
        </tbody>
    </table>
</div>


Solution 1:[1]

Solved: My string list had spaces and shouldn't have done

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Callum Brown