NZEC error in Python

前端 未结 5 1968
自闭症患者
自闭症患者 2021-01-13 13:31

this is a simple piece of code which is suppose to read n numbers and suppose to print how many numbers out of these n numbers are divisible by k

n=int(raw_i         


        
5条回答
  •  春和景丽
    2021-01-13 14:17

    You are getting NZEC error because when you enter space separated integers in python it is treated as a single string and not as two integers like in C,C++ and Java: In your case, This should work:

    n,k=map(int,raw_input().split())
    

    Also in future remember, to input an integer array separated by spaces in python is:

    a=map(int,raw_input().split())
    

提交回复
热议问题