title: validate user input by length in Python
body: <p>I have some code:</p>
  
  <pre><code>def GetPlayerName():
    print()
    PlayerName = input('Please enter your name: ')
    print()
    return PlayerName
  </code></pre>
  
  <p>How can I keep asking for the player's name until they enter a name that is more than one character long, and tell them they must enter a valid name if they leave the field blank? </p>
  
  <p>I tried</p>
  
  <pre><code>def GetPlayerName():
    print()
    PlayerName = input('Please enter your name: ')
    print()
    return PlayerName
    while len(PlayerName) &lt; 1:
      print("You must enter a name!")
  </code></pre>
  
  <p>but have been unsuccessful.</p>