11. Count


#1

Whenever I am running code I keep getting error
" File “python”, line ****
return tally
^
IndentationError: unexpected indent "

even when confirmed from moderators that the code is correct. Is there some way to fix this?
I’ve tried deleting the white space then using tab, but to no avail

the code below is my most recent example of the error - line 8

appreciate your help

thanks



def count(sequence, item):
  tally = 0
  index = -1
  for tick in range(len(sequence)):
    index += 1
    if sequence[index] == item:
      tally += 1
  return tally


#2

You can send the code over to this Python Beautifier and it will do all the dirty work for you, yor code should work fine thereafter.

http://www.cleancss.com/python-beautify/


#3

I opened a new window and it worked this time
thanks will try using it next time :slight_smile:


#4

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