2014-01-28 71 views
-1
z=list() 
t=raw_input() 
for i in range (0,int(t)): 
    x= raw_input() 
    z.append(x) 
for i in z: 
    if(i%3==0 and i%5==0): 
     print 'FizzBuzz' 
    elif(i%3==0): 
     print 'Fizz' 
    elif(i%5==0): 
     print 'Buzz' 
    else: 
     print i 
    print '\n' 

這是我的代碼。出於某種原因,我不斷收到此錯誤使用raw_input的Python中的EOF錯誤

Traceback (most recent call last): File "/tmp/editor_trsource_1390938776_887424.py", line 10, in
x= raw_input() EOFError: EOF when reading a line

+0

你是如何運行它的? – geoffspear

+0

python filename.py –

+3

什麼環境?什麼外殼?你實際上在輸入什麼? – geoffspear

回答

0

z.append(x)應該是z += [int(x)]:你需要檢查自己整除之前的字符串整數轉換。

z=list() 
t=raw_input() 
for i in range (0,int(t)): 
    x= raw_input() 
    z += [int(x)] 
for i in z: 
    if(i%3==0 and i%5==0): 
     print 'FizzBuzz' 
    elif(i%3==0): 
     print 'Fizz' 
    elif(i%5==0): 
     print 'Buzz' 
    else: 
     print i 
    print '\n' 
+1

這裏downvote的原因是什麼? –