Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d0e9e51

Browse filesBrowse files
authored
Update 16_sorting_hat_2.py
1 parent 422e615 commit d0e9e51
Copy full SHA for d0e9e51

File tree

Expand file treeCollapse file tree

1 file changed

+8
-4
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-4
lines changed

‎3-control-flow/16_sorting_hat_2.py

Copy file name to clipboardExpand all lines: 3-control-flow/16_sorting_hat_2.py
+8-4Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,15 @@
7777
print("Hufflepuff: ", hufflepuff)
7878
print("Slytherin: ", slytherin)
7979

80-
if gryffindor >= ravenclaw and gryffindor >= hufflepuff and gryffindor >= slytherin:
80+
# Bonus Part
81+
82+
most_points = max(gryffindor, ravenclaw, hufflepuff, slytherin) # We'll learn about the max() function in Chapter 6
83+
84+
if gryffindor == most_points:
8185
print('🦁 Gryffindor!')
82-
elif ravenclaw >= hufflepuff and ravenclaw >= slytherin:
86+
elif ravenclaw == most_points:
8387
print('🦅 Ravenclaw!')
84-
elif hufflepuff >= slytherin:
88+
elif hufflepuff == most_points:
8589
print('🦡 Hufflepuff!')
8690
else:
87-
print('🐍 Slytherin!')
91+
print('🐍 Slytherin!')

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.