How do I limit my users input to a single digit? (Python)
<p>I want my program to say 'invalid input' if 2 digits or more are entered so is there a way i can limit my users input to a single digit in python?</p>

<p>This is my code:</p>

<pre><code>print('List Maker')
tryagain = ""

while 'no' not in tryagain:
    list = []

    for x in range(0,10):
        number = int(input("Enter a number: "))
        list.append(number)

    print('The sum of the list is ',sum(list))
    print('The product of the list is ',sum(list) / float(len(list)))
    print('The minimum value of the list is ',min(list))
    print('The maximum vlaue of the list is ',max(list))
    print(' ')
    tryagain = input('Would you like to restart? ').lower()
    if 'no' in tryagain:
        break
print('Goodbye')
</code></pre>

<p>There is another option for getting only one character, based on this previous <a href="http://stackoverflow.com/questions/27750536/python-input-single-character-without-enter">answer</a>:</p>

<pre><code>import termios
    import sys, tty
    def getch():
        fd = sys.stdin.fileno()
        old_settings = termios.tcgetattr(fd)
        try:
            tty.setraw(fd)
            ch = sys.stdin.read(1)
        finally:
            termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
        return ch


numbers = []
while len(numbers) &lt; 10:
    try:
        ch = int(getch())
    except:
        print 'error...'
</code></pre>

python