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

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -