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'])
|
||||
def questions():
|
||||
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():
|
||||
with open(datafile, "a", newline='') as f:
|
||||
new_row = list()
|
||||
@ -81,7 +88,9 @@ def questions():
|
||||
|
||||
if len(new_row) == 6:
|
||||
new_row.append('n')
|
||||
|
||||
|
||||
magical_house_number = int(new_row[2]) % 10
|
||||
new_row.append(houses[magical_house_number])
|
||||
writer = csv.writer(f)
|
||||
writer.writerow(new_row)
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
<th>spirit_animal</th>
|
||||
<th>operating_system</th>
|
||||
<th>check</th>
|
||||
<th>house</th>
|
||||
</tr>
|
||||
{% for row in file_data %}
|
||||
<tr>
|
||||
@ -20,6 +21,7 @@
|
||||
<th>{{ row[4] }}</th>
|
||||
<th>{{ row[5] }}</th>
|
||||
<th>{{ row[6] }}</th>
|
||||
<th>{{ row[7] }}</th>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user