为什么我在Codechef的第4行的此python代码中出现nzec错误和EOFerror?

时间:2019-02-20 00:52:26

标签: python-3.x

当我在codechef上运行此代码时,出现nzec和EOF错误,但是在运行此代码时在Jupyter笔记本上没有出现任何错误,请帮助!

s=""    #empty string
import random
a=int(input(""))                      #to input an integer
b=int(input(""))                      #to input another integer
c=a-b                                 #subtracting them
d=str(c)                              #converting the result to string 
l=len(d)                              #calculating its length 
r=random.randint(0,l)                 #generating a random number to choose 
                                      #a string index
new_number=random.randint(1,10)       #generating another random number to 
                                      #replace a number in the string
string_new_number=str(new_number)     #converting the random number to 
                                      #string
for i in range(0,l):                  
    if i==r:
        s=s+string_new_number        #changing the string with the new 
                                     #generated number
    else:
        s=s+d[i]                     
print(s)

0 个答案:

没有答案