Question about iteration


#1

https://www.codecademy.com/courses/learn-python/lessons/practice-makes-perfect/exercises/scrabblescore?action=lesson_resume

I don’t have any error messages. This is a general question.
Whenever python is asked to iterate through a word letter by letter and evaluate that letter for something, where does python start? Does it start with the first letter or with the last letter?
I’m asking because I remember one of the exercises was related to numbers and a solution was to tell python to take the last digit and add it to a total, then shorten the number and loop through again.
Thanks in advance


`score = {"a": 1, "c": 3, "b": 3, "e": 1, "d": 2, "g": 2, 
         "f": 4, "i": 1, "h": 4, "k": 5, "j": 8, "m": 3, 
         "l": 1, "o": 1, "n": 1, "q": 10, "p": 3, "s": 1, 
         "r": 1, "u": 1, "t": 1, "w": 4, "v": 4, "y": 4, 
         "x": 8, "z": 10}

def scrabble_score(word):
  new_word=word.lower()
  total=0
  low=len(word)
  while low>0:
    for c in new_word:
      total=total+score[c]
      low=len(word)-1
    return total


#2

you can simply use a print statement for checking

for c in new_word:
    print c

#3

Thanks. After I crashed my computer several times, I think it starts with the first letter.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.