I'm trying to read each character from words in a list, and then assign a value to them based on each of the letters in that word. My code is stupidly long, and I'm convinced there must be a shorter way to do it...
for c in tempWord:
if(c == "A"):
tempSum += 1
elif(c == "B"):
tempSum += 2
elif(c == "C"):
tempSum += 3
elif(c == "D"):
tempSum += 4
elif(c == "E"):
tempSum += 5
elif(c == "F"):
tempSum += 6
elif(c == "G"):
tempSum += 7
elif(c == "H"):
tempSum += 8
elif(c == "I"):
tempSum += 9
elif(c == "J"):
tempSum += 10
elif(c == "K"):
tempSum += 11
elif(c == "L"):
tempSum += 12
elif(c == "M"):
tempSum += 13
elif(c == "N"):
tempSum += 14
elif(c == "O"):
tempSum += 15
elif(c == "P"):
tempSum += 16
elif(c == "Q"):
tempSum += 17
elif(c == "R"):
tempSum += 18
elif(c == "S"):
tempSum += 19
elif(c == "T"):
tempSum += 20
elif(c == "U"):
tempSum += 21
elif(c == "V"):
tempSum += 22
elif(c == "W"):
tempSum += 23
elif(c == "X"):
tempSum += 24
elif(c == "Y"):
tempSum += 25
elif(c == "Z"):
tempSum += 26
This is probably a stupid question, but thanks anyway!