Every time I run this program, the error shows in the box.

I used Windows 10 to run this program.

import random
import msvcrt
a=random.randint(1,50)
while True:
    text=('put your guess here >>>')
    b=input(text)
    print(b)
    print(a)
    while True:
        pk=msvcrt.getch()
        b=input(text)
        if int(b)>a:
            print('too large')
        if int(b)<a:
            print('too small')
        if int(b)==a:
            print('correct, you guessed the number!')
            break
        if pk == 'r':
            a=random.randint(1,50)
            print`

Traceback (most recent call last): File "main.py", line 2, in <module> import msvcrt ImportError: No module named 'msvcrt'

I expected the import to be successful, but it wasn't.

0 Answers