title: Correct way of coding a 'Guess the Number' game in Python
body: <p>I'm new to python and programming in general and I've written some code for a Guess the Number game in Python. It allows the user 6 attempts at guessing a random number. It works, however I am not sure if this is the best way or most efficient way of writing it and would appreciate it of I could get get some constructive feedback on it.</p>
  
  <p>Code:</p>
  
  <pre><code>    #Guess my Number - Exercise 3
  #Limited to 5 guesses
  
  import random 
  
  attempts = 1
  secret_number = random.randint(1,100)
  isCorrect = False
  guess = int(input("Take a guess: "))
  
  while secret_number != guess and attempts &lt; 6:
  
      if guess &lt; secret_number:
          print("Higher...")
      elif guess &gt; secret_number:
          print("Lower...")
      guess = int(input("Take a guess: "))
      attempts += 1
  
  if attempts == 6:
      print("\nSorry you reached the maximum number of tries")
      print("The secret number was ",secret_number) 
  
  else:
      print("\nYou guessed it! The number was " ,secret_number)
      print("You guessed it in ", attempts,"attempts")
  
  input("\n\n Press the enter key to exit")           
  </code></pre>