jeudi 25 mai 2017

this seems to be the same error with "if"/ [on hold]

Can I not start that line with "if"? It's tabbed over from the previous line, not enter or new line?

Sorry, this is sort of a basic question. But why does that code not run ok?

word = "183651"
sumOfOddIndexes = 0
oddIndex = False
for ch in word:                                                                         
       if oddIndex:                                                                             
             sumofOddIndexes += int(ch)                                                             
       oddIndex = not oddIndex

But of course I get a syntax error.

Aucun commentaire:

Enregistrer un commentaire