on the scrabble project Scrabble Project/ Python3
I have a question because something just happened that completely baffled me. I know indentation is VERY important in Python but I’m trying to understand in this instance what exactly happened.
So, here is the code in question:
for player,words in player_to_words.items():
player_points = 0
for word in words:
player_points += score_word(word)
player_to_points[player] = player_points
print(player_to_points)
This code above printed out the code correctly and fine… with all the players shown and the points they had.
This code below was incorrect as it only showed “Prof Reader” with 31 points. Why?! Why did that indentation do that?
for player,words in player_to_words.items():
player_points = 0
for word in words:
player_points += score_word(word)
player_to_points[player] = player_points
print(player_to_points)