python 2.7 - TypeError: getch() takes exactly 0 arguments (1 given) -
i have piece of code want if entered other 1,2,3,4 take input once again
import msvcrt answer = msvcrt.getch() while answer not in ['1','2','3','4']: answer = msvcrt.getch('enter valid option (1,2,3,4): ')
entering not in list gives error:
typeerror: getch() takes 0 arguments (1 given)
but dont know why giving me error tho appreciated
the error text self explanatory. in second line called getch correctly:
answer = msvcrt.getch()
in order code it's expected change to:
while answer not in ['1','2','3','4']: print 'enter valid option (1,2,3,4): ' answer = msvcrt.getch()
Comments
Post a Comment