2016-01-12 33 views

回答

4

嘗試:

count = count + 1 

count += 1 

不要更新計數與計數+ 1;

+0

唯一的答案其實解釋的OP的代碼錯誤。 +1 – M4rtini

2

更Python的方式是使用一個for循環:

print ("Enter a word") 
word = str(input()) 
total = len(word) 

for i in range(total-1): 
    print(word) 
0

另一種解決方案是使用字符串的乘法:

print((word+'\n')*len(word)) 
相關問題