Apr-03-2018, 01:20 PM
Hmm that's a two code put together @sylas,i do recognize a demo i did in a post before
But the first part should not be there,it's a different code.
Here how my code should look,as you just copy my
So the they point here is that there no break,code run as long as not the secret number is guessed.
secret_number = 34
But the first part should not be there,it's a different code.
Here how my code should look,as you just copy my
hint
in the other post.So the they point here is that there no break,code run as long as not the secret number is guessed.
import random secret_number = random.randint(1, 100) tries, guess = 0, 0 while guess != secret_number: guess = int(input("Guess a number (<100): ")) if guess > secret_number: print("Lower...") elif guess < secret_number: print("Higher...") tries += 1 print('You guessed it! The number was {} in {} tries'.format(guess, tries))
Output:λ python guess.py
Guess a number (<100): 50
Lower...
Guess a number (<100): 25
Higher...
Guess a number (<100): 35
Lower...
Guess a number (<100): 30
Higher...
Guess a number (<100): 32
Higher...
Guess a number (<100): 34
Lower...
Guess a number (<100): 33
You guessed it! The number was 33 in 7 tries