Last active
January 8, 2019 20:46
-
-
Save hxueh/24b4478c58eaa0d38ee62d2f89ad8311 to your computer and use it in GitHub Desktop.
matrix.html in CS50 2017 Pset6 Similarities (more comfortable)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<table class="table table-sm"> | |
<thead> | |
<tr> | |
<!--There are three empty cell in the first header--> | |
<th></th> | |
<th></th> | |
<th></th> | |
<!--s2 is the string2, according to application.py--> | |
{% for character in s2 %} | |
<th>{{character}}</th> | |
{% endfor %} | |
</tr> | |
<tr> | |
<!--Two empty cell in the second header--> | |
<th></th> | |
<th></th> | |
{% for i in range((s2)|length + 1) %} | |
<th>{{i}}</th> | |
{% endfor %} | |
</tr> | |
</thead> | |
<tbody> | |
<tr> | |
<th></th> | |
<th>0</th> | |
{% for i in matrix[0] %} | |
<th>{{i[0]}}</th> | |
{% endfor %} | |
</tr> | |
{% for t in range(s1|length) %} | |
<tr> | |
<th>{{s1[t]}}</th> | |
<th>{{t + 1}}</th> | |
{% for i in matrix[t + 1] %} | |
<td>{{ i[0] }}</td> | |
{% endfor %} | |
</tr> | |
{% endfor %} | |
</tbody> | |
</table> |
I'm not 100% certain but I think you have to include helpers.py, I wrote it like this: "{% include "helpers.py" %}" but I can't check if it works because of other errors
Can you explain why you are using
range((s2)|length + 1)
Specifically what is length?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey there, if possible, could you please give an explanation as to how you accessed the elements of the matrix in line 34 and 35?
My doubt pertains to the fact of how this indexing valid, since the matrix we generated and returned in the back end is a matrix of tuples. I generated as a list of lists, and in general, to access the number I used the syntax like -
matrix[i][j][0]
to get the number at that particular case, but here, the code successfully returns that value with just one indexing which is perplexing to me.An explanation would be appreciated