Question: I'm trying to make an algorithm where the computer tries to guess your number, knowing a maximum and minimum value, and each time it guesses, you tell it if it's guess is too low or too high(too low = troppetit, too high = tropgrand).

I'm trying to solve this using dichotomy, but without using a list, the problem I'm having is it works correctly if I only input "tropgrand" or "troppetit", but if I input "tropgrand" then "troppetit", or the opposite, it just returns the same number each time.

```
max=int(input("max"))
min=int(input("min"))
proposition=(min+max)//2
print(proposition)
reponse=""
while reponse != "juste":
    reponse=input("le nombre est-il trop grand, trop petit, ou juste ?  tropgrand/troppetit/juste")
    if reponse == "tropgrand" :
        proposition=(min+proposition)//2
        print(proposition)
        max=proposition
    elif reponse == "troppetit" :
        proposition=(proposition+max)//2
        print(proposition)
        min=proposition
    if reponse == "tropgrand" :
        proposition=(min+proposition)//2
        print(proposition)
        max=proposition
    elif reponse == "troppetit" :
        proposition=(proposition+max)//2
        print(proposition)
        min=proposition

```

Answer: 
> 
> if I input "tropgrand" then "troppetit", or the opposite, it just returns the same number each time
> 
> 
> 

Step through the code

Example,

```
min=0, max=10
proposition = 5

input: tropgrand
proposition=(0+10)//2 == 5
max = 5
proposition=(0+5)//2 == 2
max = 2

input: troppetit
proposition=(2+2)//2 == 2
min = 2
proposition=(2+2)//2 == 2
min = 2

...

```

I think you're looking for this.

1. Print at the start of the loop, that way the input statement is reflecting what was just output
2. Don't modify things more than once; the *previous guess* becomes your new high/low

```
high = int(input("upper: "))
low = int(input("lower: "))
if low > high:
  raise ValueError('Lower bound higher than upper bound')
while True:
    guess = (low+high) // 2
    print(f'Guess: {guess}')
    response = input("le nombre est-il trop grand, trop petit, ou juste ?  tropgrand/troppetit/juste ")
    if response == 'juste':
        break

    if response == 'tropgrand':
        high = guess
    if response == 'troppetit':
        low = guess

```
You are assigning the max/min variables AFTER modifying the proposition. You should set the new max BEFORE changing the proposition.

```
if reponse == "tropgrand" :
    max=proposition-1                # the number is less than proposition
    proposition=(min+proposition)//2   
    print(proposition)

elif reponse == "troppetit" :
    min=proposition+1                # the number is higher than proposition
    proposition=(proposition+max)//2
    print(proposition)

# You don't need to repeat the above code twice

```

*BTW You should avoid naming your variables min and max because those are the names of Python functions*