Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SyntaxError: Non-UTF-8 code starting with '\x91'

Tags:

python

utf-8

I am trying to write a binary search program for a class, and I am pretty sure that my logic is right, but I keep getting a non-UTF-8 error. I have never seen this error and any help/clarification would be great! Thanks a bunch.

Here's the code.

def main():


    str names = [‘Ava Fischer’, ‘Bob White’, ‘Chris Rich’, ‘Danielle Porter’, ‘Gordon Pike’, ‘Hannah Beauregard’, ‘Matt Hoyle’, ‘Ross Harrison’, ‘Sasha Ricci’, ‘Xavier Adams’]

    binarySearch(names, input(str("Please Enter a Name.")))

    print("That name is at position "+position)


def binarySearch(array, searchedValue):

    begin = 0 
    end = len(array) - 1 
    position = -1 
    found = False

    while !=found & begin<=end:
        middle=(begin+end)/2

        if array[middle]== searchedValue:
            found=True 
            position = middle
        elif array[middle] >value:
            end=middle-1
        else:
            first =middle+1
return position
like image 639
GrapeSoda3 Avatar asked Apr 15 '14 19:04

GrapeSoda3


1 Answers

Add this line at the top of you code. It may work.

    # coding=utf8
like image 107
东方魔盗 Avatar answered Oct 06 '22 09:10

东方魔盗