編寫程序,用於計算有n(1<n<10)個字符串中最長的字符串的長度。前導空格不要計算在內!
輸入格式:
在第一行中輸入n,接下的每行輸入一個字符串
輸出格式:
在一行中輸出最長的字符串的長度
輸入樣例:
在這里給出一組輸入。例如:
4
blue
yellow
red
green
輸出樣例:
在這里給出相應的輸出。例如:
length=6
n=int(input()) max = 0 maxstr = "" for i in range(0, n): s =str(input().lstrip()) if (max < len(s)): max = len(s) maxstr = s print("length=%d"%len(maxstr))