Add house sorting algorithm
This commit is contained in:
parent
03bba3fc64
commit
daac267b64
@ -71,6 +71,13 @@ def index():
|
|||||||
@app.route('/questions', methods=['GET', 'POST'])
|
@app.route('/questions', methods=['GET', 'POST'])
|
||||||
def questions():
|
def questions():
|
||||||
form = QuestionForm(request.form)
|
form = QuestionForm(request.form)
|
||||||
|
houses = dict()
|
||||||
|
houses[0] = 'knuth'
|
||||||
|
houses[1] = 'lovelace'
|
||||||
|
houses[2] = 'turing'
|
||||||
|
houses[4] = 'hopper'
|
||||||
|
houses[8] = 'lamarr'
|
||||||
|
|
||||||
if request.method == 'POST' and form.validate():
|
if request.method == 'POST' and form.validate():
|
||||||
with open(datafile, "a", newline='') as f:
|
with open(datafile, "a", newline='') as f:
|
||||||
new_row = list()
|
new_row = list()
|
||||||
@ -81,7 +88,9 @@ def questions():
|
|||||||
|
|
||||||
if len(new_row) == 6:
|
if len(new_row) == 6:
|
||||||
new_row.append('n')
|
new_row.append('n')
|
||||||
|
|
||||||
|
magical_house_number = int(new_row[2]) % 10
|
||||||
|
new_row.append(houses[magical_house_number])
|
||||||
writer = csv.writer(f)
|
writer = csv.writer(f)
|
||||||
writer.writerow(new_row)
|
writer.writerow(new_row)
|
||||||
|
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
<th>spirit_animal</th>
|
<th>spirit_animal</th>
|
||||||
<th>operating_system</th>
|
<th>operating_system</th>
|
||||||
<th>check</th>
|
<th>check</th>
|
||||||
|
<th>house</th>
|
||||||
</tr>
|
</tr>
|
||||||
{% for row in file_data %}
|
{% for row in file_data %}
|
||||||
<tr>
|
<tr>
|
||||||
@ -20,6 +21,7 @@
|
|||||||
<th>{{ row[4] }}</th>
|
<th>{{ row[4] }}</th>
|
||||||
<th>{{ row[5] }}</th>
|
<th>{{ row[5] }}</th>
|
||||||
<th>{{ row[6] }}</th>
|
<th>{{ row[6] }}</th>
|
||||||
|
<th>{{ row[7] }}</th>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user